# mikeored/codex-of-agents architecture

> Architecture diagram of the GitHub repository mikeored/codex-of-agents, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mikeored/codex-of-agents
- Repository: https://github.com/mikeored/codex-of-agents

## Overview

##### High-Level Components

a) Client Layer (Top)
- React Frontend (planned)
- API Gateway Interface

b) Application Layer
- Use Cases (e.g., InvokeScribeUseCase)
- DTOs and Schemas

c) Domain Layer (Core)
- Entities (Document, Actor, Location, Agent)
- Domain Services
- Repositories Interfaces

d) Infrastructure Layer (Bottom)
- AWS Services (Bedrock, Lambda, DynamoDB)
- Repository Implementations
- Adapters (Primary/Secondary)

##### Component Relationships

a) Primary Flow:
**Client Request → API Gateway → Primary Adapters → Use Cases → Domain Services → Secondary Adapters → AWS Services**

b) Key Interactions:
- Agent interactions with LLM Services
- Chronicle execution flow
- Repository patterns for data persistence

##### Specific Architectural Elements

Create distinct sections for:

a) Agentic System:
- Agent Entities
- Tools System
- Chronicle Management
- Session Handling

b) Content Management:
- Document Hierarchy
- Actor/Location Management
- Content Relationships

##### Important Details

a) Domain Bounded Contexts:
- Document Management Context
- Agent Management Context
- Session Management Context

b) Cross-Cutting Concerns:
- Configuration Management
- Error Handling
- Schema Validation

##### Specific Implementation Notes

Key patterns:
- Hexagonal Architecture ports/adapters
- Repository Pattern implementations
- Event-driven interactions
- Tool system extensibility points

##### AWS Infrastructure Components

Highlight:
- API Gateway endpoints
- Lambda functions
- DynamoDB tables
- Bedrock integration points

##### Session management

Remember to:
- Clear boundaries between bounded contexts
- Hexagonal architecture's ports and adapters
- Demonstrate the flow of domain events
- Integration points with AWS services

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#E1F5FE,stroke:#01579B
    classDef api fill:#E8F5E9,stroke:#1B5E20
    classDef application fill:#F3E5F5,stroke:#4A148C
    classDef domain fill:#E3F2FD,stroke:#0D47A1
    classDef infrastructure fill:#FFF3E0,stroke:#E65100
    classDef aws fill:#FFEBEE,stroke:#B71C1C
    classDef repository fill:#E0F2F1,stroke:#004D40

    %% Client Layer
    subgraph ClientLayer
        FE[React Frontend]:::frontend
        API["API Gateway Interface"]:::api
    end

    %% Application Layer
    subgraph ApplicationLayer
        UC["InvokeScribe UseCase"]:::application
        DTO["DTOs & Schemas"]:::application
    end

    %% Domain Layer
    subgraph DomainLayer
        subgraph DomainCore
            BE["Base Domain Elements"]:::domain
            DE["Domain Events"]:::domain
        end

        subgraph AgenticSystem
            AG["Agent System"]:::domain
            CH["Chronicle Management"]:::domain
            SM["Session Management"]:::domain
            TS["Tool System"]:::domain
        end

        subgraph ContentSystem
            CM["Content Management"]:::domain
        end

        subgraph DomainServices
            CES["Chronicle Executor Service"]:::domain
            LLMI["LLM Service Interface"]:::domain
        end

        subgraph RepositoryInterfaces
            BR["Base Repository"]:::repository
            AR["Agent Repository"]:::repository
            DR["Document Repository"]:::repository
            SR["Session Repository"]:::repository
        end
    end

    %% Infrastructure Layer
    subgraph InfrastructureLayer
        subgraph CrossCutting
            CF["Configuration"]:::infrastructure
            SV["Schema Validation"]:::infrastructure
            EH["Error Handling"]:::infrastructure
        end

        subgraph Implementations
            LLMS["Bedrock LLM Service"]:::infrastructure
            CE["Chronicle Executor"]:::infrastructure
            RI["Repository Implementations"]:::infrastructure
        end

        subgraph AWSServices
            BDR["AWS Bedrock"]:::aws
            LAM["AWS Lambda"]:::aws
            DDB["DynamoDB"]:::aws
        end
    end

    %% Relationships
    FE --> API
    API --> UC
    UC --> DTO
    UC --> DomainCore
    DomainCore --> AgenticSystem
    DomainCore --> ContentSystem
    AgenticSystem --> DomainServices
    ContentSystem --> RepositoryInterfaces
    DomainServices --> Implementations
    Implementations --> AWSServices
    CrossCutting -.-> DomainLayer

    %% Click Events
    click API "https://github.com/MikeORed/codex-of-agents/blob/main/src/adapters/primary/invokescribe-apigateway-adapter/invokescribe-apigateway-adapter.ts"
    click UC "https://github.com/MikeORed/codex-of-agents/blob/main/src/application/use-cases/invoke-scribe-usecase.ts"
    click DTO "https://github.com/MikeORed/codex-of-agents/blob/main/src/application/dtos/invoke-scribe-dto.ts"
    click BE "https://github.com/MikeORed/codex-of-agents/tree/main/src/domain/entities/base/"
    click AG "https://github.com/MikeORed/codex-of-agents/tree/main/src/domain/entities/agentic/agents/"
    click CH "https://github.com/MikeORed/codex-of-agents/tree/main/src/domain/entities/agentic/chronicles/"
    click SM "https://github.com/MikeORed/codex-of-agents/tree/main/src/domain/entities/agentic/sessions/"
    click TS "https://github.com/MikeORed/codex-of-agents/tree/main/src/domain/entities/agentic/tools/"
    click CM "https://github.com/MikeORed/codex-of-agents/tree/main/src/domain/entities/content/"
    click DE "https://github.com/MikeORed/codex-of-agents/blob/main/src/domain/events/domain-event.ts"
    click BR "https://github.com/MikeORed/codex-of-agents/blob/main/src/domain/repositories/base.repository.ts"
    click AR "https://github.com/MikeORed/codex-of-agents/blob/main/src/domain/repositories/agent.repository.ts"
    click DR "https://github.com/MikeORed/codex-of-agents/blob/main/src/domain/repositories/document.repository.ts"
    click SR "https://github.com/MikeORed/codex-of-agents/blob/main/src/domain/repositories/session.repository.ts"
    click LLMS "https://github.com/MikeORed/codex-of-agents/blob/main/src/adapters/secondary/llm-service/bedrock-llm-service.ts"
    click CE "https://github.com/MikeORed/codex-of-agents/blob/main/src/adapters/secondary/chronicle-executor/synchronous-in-memory-chrocnicle-executor.ts"
    click RI "https://github.com/MikeORed/codex-of-agents/blob/main/src/adapters/repositories/hardcoded/hardcoded-agent-repository.ts"
    click CES "https://github.com/MikeORed/codex-of-agents/blob/main/src/domain/services/chronicle-executor/chronicle-executor.ts"
    click LLMI "https://github.com/MikeORed/codex-of-agents/blob/main/src/domain/services/llm-service/llm-service.ts"
    click CF "https://github.com/MikeORed/codex-of-agents/blob/main/src/shared/config/config.ts"
    click SV "https://github.com/MikeORed/codex-of-agents/blob/main/src/shared/utils/schema-validator.ts"
    click EH "https://github.com/MikeORed/codex-of-agents/blob/main/src/shared/errors/index.ts"
```
