# afonsodasilva1/recipe-list architecture

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

- Interactive diagram: https://gitdiagram.com/afonsodasilva1/recipe-list
- Repository: https://github.com/afonsodasilva1/recipe-list

## Overview

##### Main Components

a) Client Layer
- External clients (Mobile/Web applications)

b) API Layer
- Express.js server (server.js)
- Routes layer (src/routes.js)
- Should be placed below the client layer

c) Application Layer
- Controllers (src/app/db/controllers)
- Repositories (src/app/db/repositories)

d) Data Layer
- Database connection (src/app/db/connection.js)

##### Component Relationships

**[External Clients]**
- ↓
**[Express Server (server.js)]**
- ↓
**[Routes (routes.js)]**
- ↓
**[Controller (receitaController.js)]**
- ↓
**[Repository (receitaRepository.js)]**
- ↓
**[Database Connection]**
- ↓
**[Database]**

##### Specific Details

API Endpoints (from README):
- POST /addAutor
- POST /addReceita
- GET /listarReceita
- GET /listarAutor
- GET /pesquisarReceita
- /editarReceita
- POST /addFavoritos
- GET /Favoritos
- DELETE /apagarReceita/:id_receita

##### Additional Elements

Environment Configuration:
- A configuration section showing .env file connection to the system

Security Layer:
- Where environment variables are used for secure configuration

##### Architectural Patterns to Highlight

- Repository Pattern: Show the separation between controllers and repositories
- MVC-like structure: Emphasize the separation of routes, controllers, and data access
- Three-tier architecture: Client, Application, and Data tiers

##### Notes

- Keep the main flow clear and centered
- Related components together
- Clear separation of concerns between layers
- Where environment variables are used
- Error handling flow (if any)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Clients
        C1[Mobile Client]:::client
        C2[Web Client]:::client
    end

    %% API Layer
    subgraph API
        S["Express Server"]:::api
        R["Routes Layer"]:::api
    end

    %% Application Layer
    subgraph Application
        subgraph Controllers
            RC["Recipe Controller"]:::controller
        end
        
        subgraph Repositories
            RR["Recipe Repository"]:::repository
        end
    end

    %% Data Layer
    subgraph Data
        DC["Database Connection"]:::data
        DB[(Database)]:::data
    end

    %% Environment Config
    EC[".env Config"]:::config

    %% Relationships
    C1 --> S
    C2 --> S
    S --> R
    R --> RC
    RC --> RR
    RR --> DC
    DC --> DB
    EC -.-> DC

    %% API Endpoints
    subgraph Endpoints
        direction TB
        E1["/addAutor"]:::endpoint
        E2["/addReceita"]:::endpoint
        E3["/listarReceita"]:::endpoint
        E4["/listarAutor"]:::endpoint
        E5["/pesquisarReceita"]:::endpoint
        E6["/editarReceita"]:::endpoint
        E7["/addFavoritos"]:::endpoint
        E8["/Favoritos"]:::endpoint
        E9["/apagarReceita/:id_receita"]:::endpoint
    end

    R --- Endpoints

    %% Click Events
    click S "https://github.com/afonsodasilva1/Recipe-List/blob/main/server.js"
    click R "https://github.com/afonsodasilva1/Recipe-List/blob/main/src/routes.js"
    click RC "https://github.com/afonsodasilva1/Recipe-List/blob/main/src/app/db/controllers/receitaController.js"
    click RR "https://github.com/afonsodasilva1/Recipe-List/blob/main/src/app/db/repositories/receitaRepository.js"
    click DC "https://github.com/afonsodasilva1/Recipe-List/blob/main/src/app/db/conection.js"
    click EC "https://github.com/afonsodasilva1/Recipe-List/blob/main/.env"

    %% Styles
    classDef client fill:#90EE90,stroke:#333,stroke-width:2px
    classDef api fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef controller fill:#FFA500,stroke:#333,stroke-width:2px
    classDef repository fill:#FFB347,stroke:#333,stroke-width:2px
    classDef data fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef config fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef endpoint fill:#F0F8FF,stroke:#333,stroke-width:1px

    %% Legend
    subgraph Legend
        L1[Client Layer]:::client
        L2[API Layer]:::api
        L3[Controller Layer]:::controller
        L4[Repository Layer]:::repository
        L5[Data Layer]:::data
        L6[Configuration]:::config
    end
```
