# elyseemb/prep_website_abdz architecture

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

- Interactive diagram: https://gitdiagram.com/elyseemb/prep_website_abdz
- Repository: https://github.com/elyseemb/prep_website_abdz

## Overview

##### Project Type and Purpose
- This is a monorepo full-stack CRM/ERP management system built with a Domain-Driven Design (DDD) architecture.
- It combines two AdonisJS backends (“main” core app and “cms” content app) with React/Inertia frontends, shared React components, RPC utilities, UnoCSS tooling, and Ansible/Docker deployment scripts.

##### High-Level Architecture Overview
- Apps (services):
– main: Core DDD application (controllers, domain entities, repositories, services) exposing HTTP APIs via AdonisJS + Inertia.
– cms: Content management system with rich editor (TipTap) and file uploads (FilePond).
- Packages (shared libraries):
– design-system: React UI components + Storybook.
– rpc: Typed RPC client powered by Tuyau.
– tooling: Shared UnoCSS configuration.
- Infrastructure & Tools:
– PostgreSQL DB.
– Reverse proxy (Nginx).
– Container orchestrator (Docker Compose).
– Deployment automation (Ansible playbooks).
– Monitoring (GoAccess logs).

##### Main Components
a. Frontends
– React/Inertia apps for “main” and “cms”, importing design-system and rpc packages.
– Storybook (design-system) for local component development.
b. Backends
– AdonisJS servers (main and cms) running in separate containers or processes.
– Domain modules (articles, collections, auth, customers, taxonomies, comments, lessons).
c. Data Stores and External Services
– PostgreSQL instance.
– File storage endpoint (S3 or local volume) used by cms.
– Email or third-party services if any.
d. Shared Packages and Tooling
– design-system (npm workspace).
– rpc client.
– UnoCSS config.
e. Deployment & Infrastructure
– Docker Compose network.
– Nginx reverse proxy.
– Ansible control node invoking playbooks for app, DB, Nginx, Node setup.
– Monitoring/metrics (GoAccess).

##### Relationships and Data Flows
- User browser → Inertia frontend → HTTP → AdonisJS controllers
- Controllers → Services → Repositories → PostgreSQL
- Frontend code imports design-system for UI, rpc for remote calls.
- cms uploads → FilePond → Storage volume or S3.
- Inter-service RPC (if any) via rpc client/tuyau.
- Ansible orchestrates Docker images (backend, frontend static server, DB, Nginx).

##### Architectural Patterns and Design Principles
- Domain-Driven Design: domain, builder, transformer, repository, value objects.
- MVC (AdonisJS controllers/models) on the backend.
- Inertia.js layer to unify server-side routing with React views.
- Monorepo with pnpm workspaces for code sharing.
- Infrastructure as code: Docker + Ansible.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User & Gateway
    Browser["User Browser"]:::frontend
    Nginx["Nginx Reverse Proxy"]:::infra

    Browser -->|"HTTP(S)"| Nginx

    %% Frontend Apps
    subgraph "Frontend Apps"
        direction TB
        MainFE["React/Inertia Main App"]:::frontend
        CMSFE["React/Inertia CMS App"]:::frontend
        Storybook["Storybook (Design System)"]:::shared
    end

    Nginx -->|"/" requests| MainFE
    Nginx -->|"/cms" requests| CMSFE

    MainFE -->|imports| SharedDesign
    MainFE -->|imports| SharedRPC
    MainFE -->|imports| SharedUno

    CMSFE -->|imports| SharedDesign
    CMSFE -->|imports| SharedRPC
    CMSFE -->|imports| SharedUno

    Storybook -->|local dev| SharedDesign

    %% Backend Apps
    subgraph "Backend Apps"
        direction TB
        MainBE["AdonisJS Main API"]:::backend
        CMSBE["AdonisJS CMS API"]:::backend
    end

    MainFE -->|"HTTP/API"| MainBE
    CMSFE -->|"HTTP/API"| CMSBE

    %% Domain Modules inside MainBE
    subgraph "Main App DDD Modules" 
        direction TB
        articles["articles"]:::backend
        collections["collections"]:::backend
        auth["auth"]:::backend
        customers["customers"]:::backend
        taxonomies["taxonomies"]:::backend
        comments["comments"]:::backend
        lessons["lessons"]:::backend
    end

    MainBE -->|uses| articles
    MainBE -->|uses| collections
    MainBE -->|uses| auth
    MainBE -->|uses| customers
    MainBE -->|uses| taxonomies
    MainBE -->|uses| comments
    MainBE -->|uses| lessons

    %% Shared Libraries
    subgraph "Shared Libraries" 
        direction TB
        SharedDesign["design-system"]:::shared
        SharedRPC["rpc (Tuyau)"]:::shared
        SharedUno["tooling (UnoCSS)"]:::shared
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        DB["PostgreSQL DB"]:::datastore
        Storage["File Storage (S3/Volume)"]:::datastore
    end

    MainBE -->|SQL| DB
    CMSBE -->|SQL| DB
    CMSFE -->|File Uploads| Storage
    CMSBE -->|Stores files| Storage

    %% Infra & Deployment
    subgraph "Infra & Deployment"
        direction TB
        DockerCompose["Docker Compose"]:::infra
        Ansible["Ansible Playbooks"]:::infra
        Monitoring["GoAccess Monitoring"]:::infra
    end

    DockerCompose -->|runs containers| Nginx
    DockerCompose -->|runs containers| MainBE
    DockerCompose -->|runs containers| CMSBE
    DockerCompose -->|runs containers| DB
    DockerCompose -->|runs containers| Storybook

    Ansible -->|provisions| DockerCompose
    Ansible -->|configures| Nginx
    Ansible -->|configures| Node

    Monitoring -->|analyzes| Nginx

    %% Click Events
    click MainBE "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/main"
    click CMSBE "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/cms"
    click MainFE "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/main/inertia"
    click CMSFE "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/cms/inertia"
    click articles "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/main/app/articles"
    click collections "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/main/app/collections"
    click auth "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/main/app/auth"
    click customers "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/main/app/customers"
    click taxonomies "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/main/app/taxonomies"
    click comments "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/main/app/comments"
    click lessons "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/main/app/lessons"
    click SharedDesign "https://github.com/elyseemb/prep_website_abdz/tree/main/packages/design-system"
    click SharedRPC "https://github.com/elyseemb/prep_website_abdz/tree/main/packages/rpc"
    click SharedUno "https://github.com/elyseemb/prep_website_abdz/blob/main/packages/tooling/src/unocss/unocss.config.ts"
    click UnoMain "https://github.com/elyseemb/prep_website_abdz/blob/main/apps/main/unocss.config.ts"
    click DockerCompose "https://github.com/elyseemb/prep_website_abdz/blob/main/apps/docker-compose.yml"
    click Ansible "https://github.com/elyseemb/prep_website_abdz/tree/main/apps/main/tools/ansible"
    click Storybook "https://github.com/elyseemb/prep_website_abdz/blob/main/packages/design-system/.storybook"
    click InertiaMain "https://github.com/elyseemb/prep_website_abdz/blob/main/apps/main/config/inertia.ts"
    click InertiaCMS "https://github.com/elyseemb/prep_website_abdz/blob/main/apps/cms/config/inertia.ts"
    click ServerMain "https://github.com/elyseemb/prep_website_abdz/blob/main/apps/main/bin/server.ts"
    click ServerCMS "https://github.com/elyseemb/prep_website_abdz/blob/main/apps/cms/bin/server.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#73B1F8,color:#073B4C
    classDef backend fill:#DFF7D8,stroke:#6EBF3B,color:#2E4600
    classDef datastore fill:#FFF4C1,stroke:#E1B000,color:#5A3E02
    classDef shared fill:#F3D9FF,stroke:#C17AFF,color:#4B0082
    classDef infra fill:#E8E8E8,stroke:#B0B0B0,color:#333333
```
