# almeydajuan/monorepo-poc architecture

> Architecture diagram of the GitHub repository almeydajuan/monorepo-poc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/almeydajuan/monorepo-poc
- Repository: https://github.com/almeydajuan/monorepo-poc

## Overview

##### Main Components Identification
The project is a monorepo containing several distinct components:

a. Core Applications:
- TicTacToe4k (a game service)
- User Service (user management)

b. Utility Modules:
- approve-script
- database-script
- metadata-generator
- infra (shared infrastructure)

**┌─ Applications Layer ─────────────────────┐**
- ┌─ TicTacToe4k ─┐    ┌─ User Service ─┐│
- Frontend      │    │ Backend API     ││
- Backend       │    │ Domain Logic    ││
- Domain Logic  │    │ Repositories    ││
- ┘    └────────────────┘ │
- ┘

**┌─ Shared Infrastructure ─────────────────┐**
- ┌─ Database ─┐   ┌─ Infrastructure ──┐ │
- Postgres   │   │ Storage           │ │
- Migrations │   │ Database Env      │ │
- ┘   └──────────────────┘  │
- ┘

**┌─ Build & Development Tools ────────────┐**
- ┌─ Scripts ──┐   ┌─ Metadata Gen ──┐  │
- Approve    │   │ YAML Config     │  │
- Database   │   │ Pipeline Config │  │
- ┘   └────────────────┘   │
- ┘

##### Component Relationships

- Service dependencies on shared infrastructure
- Database connections (especially for User Service)
- Build tool relationships with applications

##### Important Details

a. Technology Stack Indicators:
- Kotlin as primary language
- Http4k for web services
- Gradle for build system
- PostgreSQL for database

b. Key Architectural Patterns:
- Repository pattern (visible in user/repository)
- Clean Architecture (domain, backend separation)
- Hexagonal Architecture (ports and adapters in database-script)

##### Specific Implementation Notes

Annotations showing:
- Docker compose configurations for databases
- Test fixtures and testing strategy
- Metadata generation flow
- CI/CD pipeline integration (.github/workflows)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef application fill:#3498db,stroke:#2980b9,color:white
    classDef infrastructure fill:#2ecc71,stroke:#27ae60,color:white
    classDef tools fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef frontend fill:#e74c3c,stroke:#c0392b,color:white

    %% Applications Layer
    subgraph Applications
        %% TicTacToe4k
        subgraph TicTacToe4k
            T4kFront["Frontend"]:::frontend
            T4kBack["Backend"]:::application
            T4kDomain["Domain Logic"]:::application
        end

        %% User Service
        subgraph UserService
            UserAPI["Backend API"]:::application
            UserDomain["Domain Logic"]:::application
            UserRepo["Repositories"]:::application
        end
    end

    %% Shared Infrastructure Layer
    subgraph Infrastructure
        %% Database Components
        subgraph Database
            Postgres[(PostgreSQL)]:::database
            Migrations["Migrations"]:::database
        end

        %% Infrastructure Components
        subgraph InfraComponents
            Storage["Storage"]:::infrastructure
            DBEnv["Database Environment"]:::infrastructure
            DBReadiness["Database Readiness"]:::infrastructure
        end
    end

    %% Build & Development Tools Layer
    subgraph BuildTools
        subgraph Scripts
            ApproveScript["Approve Script"]:::tools
            DatabaseScript["Database Script"]:::tools
        end

        subgraph MetadataGen
            MetadataGenerator["Metadata Generator"]:::tools
            PipelineConfig["Pipeline Config"]:::tools
        end
    end

    %% Relationships
    T4kFront --> T4kBack
    T4kBack --> T4kDomain
    UserAPI --> UserDomain
    UserDomain --> UserRepo
    UserRepo --> Postgres
    DBEnv --> Postgres
    DBReadiness --> Postgres
    DatabaseScript --> Migrations
    Migrations --> Postgres

    %% Click Events
    click T4kFront "https://github.com/almeydajuan/monorepo-poc/blob/main/tictactoe4k/src/main/kotlin/com/juanalmeyda/tictactoe4k/frontend.kt"
    click T4kBack "https://github.com/almeydajuan/monorepo-poc/blob/main/tictactoe4k/src/main/kotlin/com/juanalmeyda/tictactoe4k/backend.kt"
    click T4kDomain "https://github.com/almeydajuan/monorepo-poc/blob/main/tictactoe4k/src/main/kotlin/com/juanalmeyda/tictactoe4k/domain.kt"
    click UserAPI "https://github.com/almeydajuan/monorepo-poc/blob/main/user/src/main/kotlin/com/juanalmeyda/user/backend.kt"
    click UserDomain "https://github.com/almeydajuan/monorepo-poc/blob/main/user/src/main/kotlin/com/juanalmeyda/user/domain/User.kt"
    click UserRepo "https://github.com/almeydajuan/monorepo-poc/tree/main/user/src/main/kotlin/com/juanalmeyda/user/repository/"
    click Storage "https://github.com/almeydajuan/monorepo-poc/blob/main/infra/src/main/kotlin/com/juanalmeyda/infra/storage/AppStorage.kt"
    click DBEnv "https://github.com/almeydajuan/monorepo-poc/blob/main/infra/src/main/kotlin/com/juanalmeyda/infra/storage/DatabaseEnv.kt"
    click DBReadiness "https://github.com/almeydajuan/monorepo-poc/blob/main/infra/src/main/kotlin/com/juanalmeyda/infra/storage/DatabaseReadinessCheck.kt"
    click ApproveScript "https://github.com/almeydajuan/monorepo-poc/tree/main/approve-script/src/main/kotlin/com/juanalmeyda/buildscript/approve/"
    click DatabaseScript "https://github.com/almeydajuan/monorepo-poc/tree/main/database-script/src/main/kotlin/com/juanalmeyda/buildscript/database/"
    click MetadataGenerator "https://github.com/almeydajuan/monorepo-poc/tree/main/metadata-generator/src/main/kotlin/com/juanalmeyda/metadata/"
    click Migrations "https://github.com/almeydajuan/monorepo-poc/blob/main/user/database/migrations/V1__users_table.sql"

    %% Legend
    subgraph Legend
        L1["Application Component"]:::application
        L2["Infrastructure Component"]:::infrastructure
        L3["Build Tool"]:::tools
        L4["Database Component"]:::database
        L5["Frontend Component"]:::frontend
    end
```
