Project Config Core

Architectural Context

The Project Config Core handles the storage and retrieval of configuration for a specific project. This includes tracking associated Git repositories, per-repository token management, LLM presets (e.g., Writer, Coder, Analyst), and global project secrets.

Business Logic Intent

The central intent of this module is to securely manage configurations that power AI and Git operations. It exposes a FastEndpoints interface to the React frontend while orchestrating robust updates behind the scenes using Wolverine handlers. When a project configuration is updated, the handler synchronizes repository definitions. If any new repositories are added or Git tokens are updated, it automatically delegates a CloneRepositoriesCommand to the MILTON.GitOperations worker service asynchronously via RabbitMQ to ensure the local file caches and S3 claim-checks are kept up-to-date.

Architecture & Integration

  • FastEndpoints: GetProjectConfig and UpdateProjectConfig provide simple HTTP interfaces, with policy-based authorization (MiltonPermissions.ProjectsRead / ConfigManage).
  • Wolverine Handlers: Heavy lifting is performed in UpdateProjectConfigHandler. This encapsulates complex entity mapping, token encryption via IEncryptionService, and asynchronous dispatching.
  • Entity Framework Core: The ProjectConfig and GitRepository entities form a 1-to-many relationship tracking project configurations. LLM Presets are stored as JSONB (LlmPresetsJson) to support dynamic NoSQL-style configuration without rigid schema migrations.

Mermaid Sequence Diagram

The following sequence illustrates the configuration update flow, demonstrating how changes to the Git repositories trigger an asynchronous clone operation.

sequenceDiagram
    autonumber
    actor Client
    participant API as UpdateProjectConfig Endpoint
    participant Handler as UpdateProjectConfigHandler
    participant DB as AppDbContext
    participant Crypto as IEncryptionService
    participant Rabbit as RabbitMQ

    Client->>API: PUT /projects/{id}/config
    API->>Handler: Handle(UpdateProjectConfigCommand)
    Handler->>DB: Fetch existing ProjectConfig
    
    Note over Handler, Crypto: Encrypts any provided Git tokens or API keys
    Handler->>Crypto: Encrypt(GitToken)
    Crypto-->>Handler: ciphertext
    
    Handler->>DB: SaveChangesAsync() (Syncs repositories & presets)
    
    alt If repositories are configured
        Handler->>Rabbit: SendAsync(CloneRepositoriesCommand)
    end
    
    Handler-->>API: Success Response
    API-->>Client: 200 OK

0 items under this folder.