# S2O Questra Automation

A cloud-native automation platform built on .NET 8.0 that orchestrates build and execution workflows using Argo Workflows on Kubernetes.

## Overview

S2O Questra Automation enables teams to manage, build, and execute containerized automation scripts at scale. The system provides a complete automation lifecycle from source code to execution, with full audit trails and real-time monitoring.

### Key Capabilities

- **Repository Management**: Define and track Git repositories containing automation scripts
- **Automated Builds**: Trigger Docker image builds from repositories with Argo Workflows
- **Execution Management**: Run containerized automation tasks on-demand or scheduled
- **Scheduling**: Configure cron-based schedules for recurring automation tasks
- **Real-time Tracking**: Monitor build and execution state with complete audit history

## Architecture

The system follows modern architectural principles including:

- **Event Sourcing** for complete audit trails and temporal queries
- **CQRS** for optimized read/write operations
- **Domain-Driven Design** for clear business logic organization
- **Cloud-Native** design for Kubernetes deployment
- **API-First** approach with GraphQL as the primary interface

### Core Technologies

- **.NET 8.0** - Application framework
- **HotChocolate** - GraphQL API server
- **Marten** - Event store on PostgreSQL
- **Argo Workflows** - Kubernetes-native workflow engine
- **Quartz.NET** - Enterprise job scheduling
- **MediatR** - CQRS implementation

## Project Structure

The solution contains 12 projects organized into functional layers:

- **Automation.Service** - ASP.NET Core application host
- **Automation.GraphQL** - GraphQL API layer
- **Automation.Core** - Business logic and CQRS handlers
- **Automation.Database** - Event store and read models
- **AutomationCommon.*** - Shared infrastructure libraries

## Getting Started

### Prerequisites

- .NET 8.0 SDK
- Kubernetes cluster with Argo Workflows installed
- PostgreSQL 14+
- Docker registry access

### Configuration

The application requires configuration for:

- PostgreSQL connection string
- Kubernetes cluster access
- Argo Workflows endpoint
- Container registry credentials
- External authorization service

### Running the Application

```bash
# Restore dependencies
dotnet restore

# Build the solution
dotnet build

# Run tests
dotnet test

# Start the service
dotnet run --project Automation.Service
```

The GraphQL API will be available at the configured endpoint (default: `/graphql`).

## Key Features

### Event Sourcing
All state changes are captured as immutable events, providing:
- Complete audit trail of all operations
- Ability to query system state at any point in time
- Event replay for debugging and troubleshooting
- Foundation for event-driven architecture

### GraphQL API
Modern API with:
- Schema-first design
- Efficient data loading with DataLoaders
- Built-in filtering, sorting, and pagination
- Claims-based authorization

### Background Services
Long-running services for:
- Monitoring Argo Workflow status
- Processing build requests
- Managing execution lifecycles
- Scheduling automated tasks

## Documentation

- [Architecture Documentation](docs/Architecture.md) - Detailed system architecture and design patterns
- [Project Structure](docs/Projects.md) - Comprehensive project and module overview

## Quality Attributes

- **Performance**: Optimized read models and efficient query patterns
- **Scalability**: Horizontal scaling with event sourcing
- **Reliability**: Retry policies and fault tolerance
- **Security**: JWT authentication and claims-based authorization
- **Observability**: OpenTelemetry metrics, structured logging, and health checks

## Contributing

When contributing to this project:

1. Follow the established architectural patterns (CQRS, Event Sourcing)
2. Write unit tests for business logic
3. Update read model projections when adding new events
4. Document GraphQL schema changes
5. Ensure background services handle failures gracefully

## Support

For issues and questions, please refer to the project documentation or contact the development team.

---

**Built with .NET 8.0 | Powered by Kubernetes & Argo Workflows**
