# gustavofringgg/metawall architecture

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

- Interactive diagram: https://gitdiagram.com/gustavofringgg/metawall
- Repository: https://github.com/gustavofringgg/metawall

## Overview

##### Main Components Identification

a. API Layer
- Main API endpoints grouped by functionality:
- Auth Routes (/auth)
- Post Routes (/post)
- User Routes (/user)
- Upload Routes (/upload)

b. Core Services Layer
- Authentication Service (service/auth.js)
- Firebase Service (service/firebase.js)
- Image Service (service/image.js)
- Error Handling Service (service/appError.js, service/handleErrorAsync.js)
- Success Handler (service/handleSuccess.js)

c. Controller Layer
- Auth Controller
- Post Controller
- User Controller
- Upload Controller

d. Data Layer
- User Model
- Post Model
- Comments Model

e. External Services
- Firebase (for file storage)
- Passport.js (for authentication)

##### Connection Flow

- Client → API Routes
- Routes → Controllers
- Controllers → Services
- Services → Models
- Services ↔ External Services (Firebase)
- Authentication flow through Passport.js

##### Technical Stack Indicators

- Node.js runtime
- Express.js framework
- MongoDB (assumed from the model structure)
- Firebase
- Passport.js

##### Additional Details

Notes about:
- Error handling strategy
- Authentication flow
- File upload process
- API documentation (Swagger integration)

##### The modular nature of the application

This architectural representation will help developers understand the flow of data and responsibilities within the system while highlighting the key architectural decisions made in the project's design.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CL[Client Applications]
    end

    subgraph API_Gateway
        direction TB
        AR["/auth"]:::api
        PR["/post"]:::api
        UR["/user"]:::api
        UPR["/upload"]:::api
    end

    subgraph Controllers
        direction TB
        AC[Auth Controller]:::controller
        PC[Post Controller]:::controller
        UC[User Controller]:::controller
        UPC[Upload Controller]:::controller
    end

    subgraph Services
        direction TB
        AS[Auth Service]:::service
        FS[Firebase Service]:::service
        IS[Image Service]:::service
        EH[Error Handler]:::service
        SH[Success Handler]:::service
    end

    subgraph Data_Layer
        direction TB
        UM[(User Model)]:::model
        PM[(Post Model)]:::model
        CM[(Comments Model)]:::model
    end

    subgraph External_Services
        direction TB
        FB[Firebase]:::external
        PS[Passport.js]:::external
        DB[(MongoDB)]:::external
    end

    %% Connections
    CL --> API_Gateway
    AR --> AC
    PR --> PC
    UR --> UC
    UPR --> UPC

    AC --> AS
    PC --> Services
    UC --> Services
    UPC --> IS
    UPC --> FS

    AS --> UM
    Services --> PM
    Services --> CM
    Services --> UM

    AS <--> PS
    FS <--> FB
    Data_Layer <--> DB

    %% Click Events
    click AR "https://github.com/GustavoFringgg/Metawall/blob/main/routes/auth.js"
    click PR "https://github.com/GustavoFringgg/Metawall/blob/main/routes/post.js"
    click UR "https://github.com/GustavoFringgg/Metawall/blob/main/routes/user.js"
    click UPR "https://github.com/GustavoFringgg/Metawall/blob/main/routes/upload.js"
    
    click AC "https://github.com/GustavoFringgg/Metawall/blob/main/controllers/authController.js"
    click PC "https://github.com/GustavoFringgg/Metawall/blob/main/controllers/postController.js"
    click UC "https://github.com/GustavoFringgg/Metawall/blob/main/controllers/userController.js"
    click UPC "https://github.com/GustavoFringgg/Metawall/blob/main/controllers/uploadController.js"
    
    click AS "https://github.com/GustavoFringgg/Metawall/blob/main/service/auth.js"
    click FS "https://github.com/GustavoFringgg/Metawall/blob/main/service/firebase.js"
    click IS "https://github.com/GustavoFringgg/Metawall/blob/main/service/image.js"
    click EH "https://github.com/GustavoFringgg/Metawall/blob/main/service/appError.js"
    click SH "https://github.com/GustavoFringgg/Metawall/blob/main/service/handleSuccess.js"
    
    click UM "https://github.com/GustavoFringgg/Metawall/blob/main/model/users.js"
    click PM "https://github.com/GustavoFringgg/Metawall/blob/main/model/posts.js"
    click CM "https://github.com/GustavoFringgg/Metawall/blob/main/model/comments.js"
    
    click PS "https://github.com/GustavoFringgg/Metawall/blob/main/connections/passport.js"
    click DB "https://github.com/GustavoFringgg/Metawall/blob/main/connections/index.js"

    %% Styles
    classDef api fill:#2196F3,stroke:#000,stroke-width:1px,color:white
    classDef controller fill:#4CAF50,stroke:#000,stroke-width:1px,color:white
    classDef service fill:#FFC107,stroke:#000,stroke-width:1px,color:black
    classDef model fill:#9C27B0,stroke:#000,stroke-width:1px,color:white
    classDef external fill:#757575,stroke:#000,stroke-width:1px,color:white

    %% Legend
    subgraph Legend
        L1[API Routes]:::api
        L2[Controllers]:::controller
        L3[Services]:::service
        L4[(Data Models)]:::model
        L5[External Services]:::external
    end
```
