# pt-hieu/lettutor-crm architecture

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

- Interactive diagram: https://gitdiagram.com/pt-hieu/lettutor-crm
- Repository: https://github.com/pt-hieu/lettutor-crm

## Overview

- Apollo – the main backend service (using NestJS as indicated by the configuration and module structure) handling core CRM business logic like actions, user management, auth, deals, feeds, files, logs, notifications, etc.
- Artemis – the frontend web application (built with Next.js/React, as seen from pages, components, and style configurations) providing the user interface.
- Hades – the migration service that manages database schema changes through migration scripts.
- Poseidon – a CMS (Content Management System) which likely handles content-related admin functions for the CRM.
- Athena – the infrastructure provisioning layer built with Terraform where AWS resources (VPCs, EC2 instances, ALBs, etc.) are defined.
- Additional microservices such as Ares and Zeus – both built with NestJS (they include nest-cli.json, .env, and similar structures) likely provide supporting functionalities (e.g., AWS operations in Ares, event handling or JWT-based logic in Zeus).

##### Main Components
- Backend API (Apollo): Include its sub-modules like Auth, Action, Deal-Stage, Feed, File, Log, Mail, Module, Note, Notification, Role, Task, User, etc.
- Frontend (Artemis): Represent pages (login, settings, report, task, etc.) and components, indicating the client-side UI.
- CMS (Poseidon): Highlight its API endpoints, admin configuration, and content management modules.
- Migration (Hades): Show its role in running DB migrations, with connections to the database.
- Additional services (Ares, Zeus): Represent these as auxiliary backend services that interact with the main application, maybe focusing on specialized tasks (like AWS integrations or specific event handling).

##### Establish Relationships and Interactions
- The Frontend (Artemis) communicates via HTTP/REST (or potentially GraphQL) with the Backend (Apollo) and CMS (Poseidon).
- Apollo and potentially other backend services (Ares, Zeus) interact with a shared database (or multiple databases) and external services (like mail and file storage).
- Hades (Migration) connects to the same database used by these services to ensure the schema is current.
- Athena (Terraform) represents the infrastructure layer that provisions and manages the cloud resources required to host these services.
- CI/CD integration: Show that GitHub workflows (stored in .github/workflows) trigger builds, tests, and deploys for these services using Dockerfiles and docker-compose files in the docker directory.

##### Architectural Patterns and Technologies
- Microservices architecture and the clear separation of concerns:
- Backend services follow the NestJS framework and an MVC-like module structure.
- The Frontend is built using a framework (likely Next.js based on file naming and page structure), incorporating component-based design.
- Infrastructure as Code is managed by Terraform (Athena) for automated cloud resource setup.

##### Final Checklist
- Be detailed: Break down internal modules where useful (for example, list out the key modules in Apollo or the major pages/components in Artemis) to provide a clear technical overview.
- Both logical (service interactions, API calls, data migrations) and infrastructural elements (deployment pipelines, infrastructure provisioning via Terraform).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Artemis["Artemis Frontend\n(Next.js/React)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        Apollo["Apollo Backend\n(NestJS)\nModules: Auth, Action, Deal, Feed, File, Log, Mail, Module, Note, Notification, Role, Task, User"]:::backend
        Ares["Ares Service\n(NestJS)"]:::backend
        Zeus["Zeus Service\n(NestJS)"]:::backend
    end

    %% CMS Layer
    subgraph "CMS Layer"
        Poseidon["Poseidon CMS\n(Content Management)"]:::cms
    end

    %% Migration Service
    subgraph "Migration Service"
        Hades["Hades Migrations\n(Database Schema Updates)"]:::migration
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Athena["Athena Terraform\n(Infrastructure Provisioning)"]:::infra
    end

    %% CI/CD Pipeline and Shared Database
    CI_CD["CI/CD Pipeline\n(GitHub Actions & Docker)"]:::cicd
    Database["Database[(Database)]"]:::db

    %% Interactions
    Artemis -->|"HTTP/REST"| Apollo
    Artemis -->|"HTTP/REST"| Poseidon

    Apollo -->|"DBAccess"| Database
    Ares   -->|"DBAccess"| Database
    Zeus   -->|"DBAccess"| Database

    Hades  -->|"SchemaUpdates"| Database

    CI_CD -->|"BuildDeploy"| Apollo
    CI_CD -->|"BuildDeploy"| Artemis
    CI_CD -->|"BuildDeploy"| Poseidon
    CI_CD -->|"BuildDeploy"| Ares
    CI_CD -->|"BuildDeploy"| Zeus
    CI_CD -->|"BuildDeploy"| Hades

    Athena -->|"Provision"| Apollo
    Athena -->|"Provision"| Artemis
    Athena -->|"Provision"| Poseidon
    Athena -->|"Provision"| Ares
    Athena -->|"Provision"| Zeus
    Athena -->|"Provision"| Hades

    %% Click Events
    click Apollo "https://github.com/pt-hieu/lettutor-crm/tree/dev/apollo"
    click Artemis "https://github.com/pt-hieu/lettutor-crm/tree/dev/artemis"
    click Hades "https://github.com/pt-hieu/lettutor-crm/tree/dev/hades"
    click Poseidon "https://github.com/pt-hieu/lettutor-crm/tree/dev/poseidon"
    click Athena "https://github.com/pt-hieu/lettutor-crm/tree/dev/athena"
    click Ares "https://github.com/pt-hieu/lettutor-crm/tree/dev/ares"
    click Zeus "https://github.com/pt-hieu/lettutor-crm/tree/dev/zeus"

    %% Styles
    classDef frontend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef backend fill:#fcc,stroke:#333,stroke-width:2px;
    classDef cms fill:#cfc,stroke:#333,stroke-width:2px;
    classDef migration fill:#e0bbf0,stroke:#333,stroke-width:2px;
    classDef infra fill:#fed,stroke:#333,stroke-width:2px;
    classDef cicd fill:#9cf,stroke:#333,stroke-width:2px;
    classDef db fill:#ffe,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
```
