# carlos3g/echoes architecture

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

- Interactive diagram: https://gitdiagram.com/carlos3g/echoes
- Repository: https://github.com/carlos3g/echoes

## Overview

##### Main Components Overview
The system consists of three main packages:
- API (NestJS backend)
- Web App (Next.js frontend)
- Mobile App (React Native)

##### Key Architectural Elements

A. Backend (API) Layer:
- Core Modules:
- Auth (authentication/authorization)
- Quote (main business logic)
- Author
- Category
- Tag
- User
- Storage (file handling)
- Email (communications)

B. Database Layer:
- PostgreSQL (indicated by Prisma usage)
- Prisma as ORM

C. Frontend Layers:
- Web Application (Next.js)
- Mobile Application (React Native)

**[Client Layer]**

- Web App      |    |  Mobile App    |
- (Next.js)      |    | (React Native) |

- ↓                    ↓

- ↓                    ↓
**[API Gateway Layer]**

- NestJS API             |

- Auth Module                    |
- Quote Module                   |
- Author Module                  |
- Category Module               |
- Tag Module                    |
- User Module                   |

- ↓                    ↓
**[Service Layer]**

- Storage (S3)  |    |  Email Service |

- ↓
**[Database Layer]**

- PostgreSQL              |
- (Prisma)               |

##### Important Relationships to Highlight
- Authentication flow between clients and API
- Data flow for quote operations
- File storage operations for user avatars
- Email service integration for user communications

##### Additional Technical Details
- Docker container boundaries
- Infrastructure components from the /infrastructure directory
- REST API endpoints
- Public vs. authenticated routes

##### Notes for Implementation
- Clear labels for all components

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that impact the system's scalability, maintainability, and security.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        WebApp["Web App (Next.js)"]:::client
        MobileApp["Mobile App (React Native)"]:::client
    end

    subgraph API["API Gateway Layer"]
        NestAPI["NestJS API"]:::api
        subgraph Modules["Core Modules"]
            direction TB
            AuthMod["Auth Module"]:::module
            QuoteMod["Quote Module"]:::module
            AuthorMod["Author Module"]:::module
            CategoryMod["Category Module"]:::module
            TagMod["Tag Module"]:::module
            UserMod["User Module"]:::module
            StorageMod["Storage Module"]:::module
            EmailMod["Email Module"]:::module
        end
    end

    subgraph Services["Service Layer"]
        S3["Storage (S3)"]:::external
        EmailService["Email Service"]:::external
    end

    subgraph DB["Database Layer"]
        Postgres["PostgreSQL (Prisma)"]:::database
    end

    %% Relationships
    WebApp --> NestAPI
    MobileApp --> NestAPI
    NestAPI --> Modules
    StorageMod --> S3
    EmailMod --> EmailService
    Modules --> Postgres

    %% Click Events
    click WebApp "https://github.com/carlos3g/echoes/tree/dev/packages/webapp/"
    click MobileApp "https://github.com/carlos3g/echoes/tree/dev/packages/app/"
    click NestAPI "https://github.com/carlos3g/echoes/blob/dev/packages/api/src/app.module.ts"
    click AuthMod "https://github.com/carlos3g/echoes/tree/dev/packages/api/src/auth/"
    click QuoteMod "https://github.com/carlos3g/echoes/tree/dev/packages/api/src/quote/"
    click AuthorMod "https://github.com/carlos3g/echoes/tree/dev/packages/api/src/author/"
    click CategoryMod "https://github.com/carlos3g/echoes/tree/dev/packages/api/src/category/"
    click TagMod "https://github.com/carlos3g/echoes/tree/dev/packages/api/src/tag/"
    click UserMod "https://github.com/carlos3g/echoes/tree/dev/packages/api/src/user/"
    click StorageMod "https://github.com/carlos3g/echoes/tree/dev/packages/api/src/storage/"
    click EmailMod "https://github.com/carlos3g/echoes/tree/dev/packages/api/src/email/"
    click S3 "https://github.com/carlos3g/echoes/blob/dev/packages/api/src/storage/services/s3-storage.service.ts"
    click EmailService "https://github.com/carlos3g/echoes/blob/dev/packages/api/src/email/services/email-service.service.ts"
    click Postgres "https://github.com/carlos3g/echoes/blob/dev/packages/api/prisma/schema.prisma"

    %% Styles
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef module fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        Client_["Client Applications"]:::client
        API_["API Services"]:::api
        Module_["API Modules"]:::module
        External_["External Services"]:::external
        Database_["Database"]:::database
    end
```
