# tex-corver/core architecture

> Architecture diagram of the GitHub repository tex-corver/core, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tex-corver/core
- Repository: https://github.com/tex-corver/core

## Overview

##### Main Components
a. CI/CD pipeline
- GitHub Actions workflows (`.github/workflows/ci.yaml`, `sync-to-A-Team-VPL.yaml`)
- Docker build (Dockerfile, Makefile)
b. Microservice runtime
- Bootstrapper (`src/core/bootstrap.py`)
- Dependency Injection container (`src/core/dependency_injection.py`)
- Configurations loader (`src/core/configurations.py`)
c. Application layers (DDD style)
- Presentation layer (`src/core/views.py`) – HTTP or CLI entrypoints
- Application layer (`src/core/message_bus.py`, `src/core/messages.py`) – command/event dispatcher
- Domain layer (`src/core/models.py`, `src/core/abstract.py`, `src/core/unit_of_work.py`)
- Infrastructure layer (`src/core/adapters/sqlalchemy_adapter.py`, `src/core/orm.py`)
d. External systems
- PostgreSQL database (configured via env vars or files per README)
- Any external microservices or message brokers (hinted by `microservices.yaml` in `.ci-config`)

##### Relationships & Data Flows
- Developer push → triggers GitHub Actions (ci.yaml) → builds Docker image → runs tests → optionally deploys
- Container startup → `bootstrap.py` reads `configurations.py` → sets up DI container via `dependency_injection.py`
- Incoming request → hits `views.py` → translates to a Command/Query message → sent into `message_bus.py`
- `message_bus` dispatches to appropriate handler (registered via DI) → uses `unit_of_work.py` and domain `models.py`
- Repository implementations in `sqlalchemy_adapter.py` perform CRUD on PostgreSQL via `orm.py`
- Results or domain events flow back through `message_bus` to `views`, then returned as HTTP/CLI response

##### Architectural Patterns & Design Principles
- Layered (hexagonal/ports-and-adapters) architecture
- Dependency Injection for decoupling wiring (core vs adapters)
- Unit of Work pattern for transactional boundaries
- Message Bus (in-process) enabling commands/events routing
- Adapter pattern isolating ORM (SQLAlchemy) from domain

##### Technologies & Frameworks
- Python packaging (pyproject.toml, setup.py)
- SQLAlchemy (ORM)
- pytest for unit/integration/e2e tests
- Docker (containerization)
- GitHub Actions (CI/CD)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actors
    Developer["Developer"]:::external

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        GH1[".github/workflows/ci.yaml"]:::external
        GH2[".github/workflows/sync-to-A-Team-VPL.yaml"]:::external
        DF["Dockerfile"]:::external
        MF["Makefile"]:::external
    end

    Developer-->GH1
    Developer-->GH2
    GH1-->DF
    GH2-->DF
    DF-->MF
    MF-->|"build & test"| ContainerStart["Run Container"]:::external

    %% Microservice Boundary
    subgraph "Microservice Boundary"
        ContainerStart-->Bootstrap["Bootstrapper"]:::code
        Bootstrap-->Config["Configuration Loader"]:::code
        Config-->DI["Dependency Injection Container"]:::code

        %% Presentation Layer
        subgraph "Presentation Layer"
            Views["views.py"]:::code
        end
        DI-->Views

        %% Application Layer
        subgraph "Application Layer"
            MB["message_bus.py"]:::code
            Msg["messages.py"]:::code
        end
        Views-->MB
        MB-->Msg

        %% Domain Layer
        subgraph "Domain Layer"
            DM["models.py"]:::domain
            AB["abstract.py"]:::domain
            UoW["unit_of_work.py"]:::domain
        end
        Msg-->DM
        DM-->AB
        AB-->UoW

        %% Infrastructure Layer
        subgraph "Infrastructure Layer"
            SA["sqlalchemy_adapter.py"]:::infra
            ORM["orm.py"]:::infra
        end
        UoW-->SA
        SA-->ORM
    end

    %% External Systems
    SA-->Postgres["PostgreSQL"]:::external
    SA-->ExtService["Other Microservices"]:::external

    %% External Configurations
    subgraph "External Configurations"
        DBConf[".ci-config/database.yaml"]:::external
        MSConf[".ci-config/microservices.yaml"]:::external
    end

    %% Click Events
    click GH1 "https://github.com/tex-corver/core/blob/master/.github/workflows/ci.yaml"
    click GH2 "https://github.com/tex-corver/core/blob/master/.github/workflows/sync-to-A-Team-VPL.yaml"
    click DF "https://github.com/tex-corver/core/tree/master/Dockerfile"
    click MF "https://github.com/tex-corver/core/tree/master/Makefile"
    click Bootstrap "https://github.com/tex-corver/core/blob/master/src/core/bootstrap.py"
    click Config "https://github.com/tex-corver/core/blob/master/src/core/configurations.py"
    click DI "https://github.com/tex-corver/core/blob/master/src/core/dependency_injection.py"
    click Views "https://github.com/tex-corver/core/blob/master/src/core/views.py"
    click MB "https://github.com/tex-corver/core/blob/master/src/core/message_bus.py"
    click Msg "https://github.com/tex-corver/core/blob/master/src/core/messages.py"
    click DM "https://github.com/tex-corver/core/blob/master/src/core/models.py"
    click AB "https://github.com/tex-corver/core/blob/master/src/core/abstract.py"
    click UoW "https://github.com/tex-corver/core/blob/master/src/core/unit_of_work.py"
    click SA "https://github.com/tex-corver/core/blob/master/src/core/adapters/sqlalchemy_adapter.py"
    click ORM "https://github.com/tex-corver/core/blob/master/src/core/orm.py"
    click DBConf "https://github.com/tex-corver/core/blob/master/.ci-config/database.yaml"
    click MSConf "https://github.com/tex-corver/core/blob/master/.ci-config/microservices.yaml"

    %% Styles
    classDef code fill:#ADD8E6,stroke:#000
    classDef domain fill:#90EE90,stroke:#000
    classDef infra fill:#FFA500,stroke:#000
    classDef external fill:#D3D3D3,stroke:#000

    class Developer,Postgres,ExtService,DBConf,MSConf external
    class GH1,GH2,DF,MF external
    class ContainerStart external
```
