# eduardosz98/cccat18_8 architecture

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

- Interactive diagram: https://gitdiagram.com/eduardosz98/cccat18_8
- Repository: https://github.com/eduardosz98/cccat18_8

## Overview

##### Project type and purpose
- This is a full-stack, microservice-based ride-hailing application built in Node.js/TypeScript, demonstrating Clean Architecture principles.
- It comprises five backend services—Account, Ride, Payment, Invoice, Query—plus two alternative frontends (React & Vue), end-to-end tests, Docker-Compose orchestration, and SQL scripts for schema creation.

##### File structure
- Top-level directories:
- backend/ — five isolated services, each with its own src/, tests, DI setup, HTTP server, database connection, queue integration, logger, gateways, repositories, application/use-cases, domain layer.
- frontend/react/ and frontend/vue/ — two SPA clients following MVC/Flux, each with its own HTTP client, domain models, and gateway abstractions.
- e2e/ — Playwright tests for cross-service user flows.
- docker-compose.yml, SQL scripts, ecosystem.config.js — deployment/orchestration.
- Each backend is a standalone process (HttpServer.ts in main.ts), uses its own database (create_xxx.sql), interacts via REST and message queues, and dispatches/consumes domain events.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontends"
        React["React SPA"]:::frontend
        Vue["Vue SPA"]:::frontend
    end

    subgraph "Backend Microservices"
        subgraph "Account Service"
            A["Account Service – HTTP + Use-Cases + Domain + DI"]:::micro
            ADB["Account DB"]:::database
        end
        subgraph "Ride Service"
            R["Ride Service – HTTP + Use-Cases + Events"]:::micro
            RDB["Ride DB"]:::database
        end
        subgraph "Payment Service"
            P["Payment Service – HTTP + Use-Cases + Fallback"]:::micro
            PDB["Payment DB"]:::database
        end
        subgraph "Invoice Service"
            I["Invoice Service – HTTP + Use-Cases"]:::micro
            IDB["Invoice DB"]:::database
        end
        subgraph "Query Service"
            Q["Query Service – HTTP + CQRS + Projections"]:::micro
            QDB["Query DB"]:::database
        end
    end

    React -->|"HTTP (REST)"| A
    Vue -->|"HTTP (REST)"| A
    React -->|"HTTP (REST)"| R
    Vue -->|"HTTP (REST)"| R
    React -->|"HTTP (REST)"| P
    Vue -->|"HTTP (REST)"| P
    React -->|"HTTP (REST)"| I
    Vue -->|"HTTP (REST)"| I
    React -->|"HTTP (REST)"| Q
    Vue -->|"HTTP (REST)"| Q

    A -->|"CRUD"| ADB
    R -->|"CRUD"| RDB
    P -->|"CRUD"| PDB
    I -->|"CRUD"| IDB
    Q -->|"CRUD"| QDB

    subgraph "Message Broker"
        Broker["RabbitMQ"]:::broker
    end

    R -->|"AMQP publish RideEvents"| Broker
    A -->|"AMQP subscribe"| Broker
    P -->|"AMQP pub/sub PaymentEvents"| Broker
    I -->|"AMQP subscribe"| Broker
    Q -->|"AMQP subscribe"| Broker

    subgraph "External Systems"
        Mailer["Mailer Gateway"]:::external
        Cielo["Cielo Gateway"]:::external
        PJBank["PJBank Gateway"]:::external
    end

    A -->|"Send Email"| Mailer
    P -->|"Process Payment"| Cielo
    P -->|"Process Payment"| PJBank

    subgraph "Orchestration"
        DC["Docker-Compose"]:::infra
        PM2["PM2 (ecosystem.config.js)"]:::infra
        SQL["SQL Schema Scripts"]:::infra
    end

    DC --> A
    DC --> R
    DC --> P
    DC --> I
    DC --> Q

    classDef frontend fill:#D6EAF8,stroke:#3498DB,color:#1F618D
    classDef micro fill:#D5F5E3,stroke:#27AE60,color:#1D8348
    classDef database fill:#FCF3CF,stroke:#F1C40F,color:#B7950B
    classDef broker fill:#E8DAEF,stroke:#8E44AD,color:#6C3483
    classDef external fill:#E5E7E9,stroke:#7F8C8D,color:#566573
    classDef infra fill:#F2F3F4,stroke:#ABB2B9,color:#566573

    click React "https://github.com/eduardosz98/cccat18_8/tree/master/frontend/react"
    click Vue "https://github.com/eduardosz98/cccat18_8/tree/master/frontend/vue"
    click A "https://github.com/eduardosz98/cccat18_8/blob/master/backend/account/src/infra/http/HttpServer.ts"
    click A "https://github.com/eduardosz98/cccat18_8/blob/master/backend/account/src/infra/controller/AccountController.ts"
    click A "https://github.com/eduardosz98/cccat18_8/blob/master/backend/account/src/infra/repository/AccountRepository.ts"
    click ADB "https://github.com/eduardosz98/cccat18_8/blob/master/backend/account/src/infra/database/DatabaseConnection.ts"
    click A "https://github.com/eduardosz98/cccat18_8/blob/master/backend/account/src/infra/di/DI.ts"
    click A "https://github.com/eduardosz98/cccat18_8/blob/master/backend/account/src/infra/gateway/MailerGateway.ts"
    click R "https://github.com/eduardosz98/cccat18_8/blob/master/backend/ride/src/infra/http/HttpServer.ts"
    click R "https://github.com/eduardosz98/cccat18_8/blob/master/backend/ride/src/infra/controller/RideController.ts"
    click P "https://github.com/eduardosz98/cccat18_8/blob/master/backend/payment/src/infra/http/HttpServer.ts"
    click P "https://github.com/eduardosz98/cccat18_8/blob/master/backend/payment/src/infra/controller/PaymentController.ts"
    click I "https://github.com/eduardosz98/cccat18_8/blob/master/backend/invoice/src/infra/http/HttpServer.ts"
    click Q "https://github.com/eduardosz98/cccat18_8/blob/master/backend/query/src/infra/http/HttpServer.ts"
    click DC "https://github.com/eduardosz98/cccat18_8/blob/master/docker-compose.yml"
    click PM2 "https://github.com/eduardosz98/cccat18_8/blob/master/ecosystem.config.js"
```
