# qtvo93/web-dev-app-pern architecture

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

- Interactive diagram: https://gitdiagram.com/qtvo93/web-dev-app-pern
- Repository: https://github.com/qtvo93/web-dev-app-pern

## Overview

##### Main Components
- Frontend (React application): Located in the “todo” directory. Contains pages and components for Landing, Login, Register, and a dashboard with various Todo operations (create, edit, delete, search, and filter).
- Backend (Express/Node.js server): Found in the “back-end” directory. This provides API endpoints for user authentication, dashboard operations, and managing todo tasks. It is organized with subdirectories like “renders” (likely for handling different route responses) and “validations” (for authenticating and validating requests).
- Database (Postgres): Configured manually or via Docker. The README includes SQL commands for setting up “users” and “todos” tables along with the necessary UUID and foreign key relationships.
- Additional Infrastructure: Docker setup with a docker-compose.yml and Dockerfiles (in both “back-end” and “todo”) showing containerized deployments for both the frontend and backend.

##### Relationships and Interactions
- The User interacts with the application through a web browser which loads the React frontend.
- The React frontend communicates with the backend (Express server) via API calls (e.g., to handle authentication, todo CRUD operations, search, filter, and even email functions).
- The backend interacts with the Postgres database for storing user data and todos.
- Docker containers wrap the frontend and backend services and coordinate with the database container if included.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The project clearly separates concerns by isolating the frontend and backend code into different directories/containers.
- MVC-like Structure in Backend: While not touched on directly in the file names, the “renders” and “validations” directories hint at a separation between business logic (validation and security) and presentation (route response rendering).
- Containerization: Docker and docker-compose configurations are used, suggesting an emphasis on environment consistency and microservice/container orchestration.
- RESTful API Communication: The React frontend likely communicates with the Node/Express backend over standard REST APIs.

##### Relevant Technologies, Frameworks, and Libraries
- React (in the “todo/src” folder) for the frontend
- Node.js with Express (in the “back-end” directory)
- PostgreSQL as the relational database
- Docker for containerization and deployment (using Dockerfile for “back-end” and “todo”)
- Additional libraries for validations, authentication (e.g., JSON Web Token using the provided jwtSecret), and potentially email services.

##### Bringing It All Together
- Optionally, include a layer that represents Docker infrastructure to show that both the frontend and backend may be running in separate containers as per the Docker setup.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["User/Browser"]:::browser

    subgraph "Frontend Container"
        B["React Frontend"]:::frontend
        C["Dockerfile (Frontend)"]:::docker
    end

    subgraph "Backend Container"
        D["Express/Node Backend"]:::backend
        E["Dockerfile (Backend)"]:::docker
        F["Request Validation"]:::backend
        G["Authorization"]:::backend
        H["Auth API"]:::backend
        I["Dashboard API"]:::backend
    end

    J["Postgres Database\n(Users & Todos)"]:::database
    K["Docker Compose"]:::compose

    %% Flow Connections
    A -->|"HTTP-request"| B
    B -->|"API-call"| D
    D -->|"validate"| F
    D -->|"authorize"| G
    F -->|"routes to"| H
    G -->|"routes to"| I
    H -->|"DB-query"| J
    I -->|"DB-query"| J
    K -->|"orchestrates"| C
    K -->|"orchestrates"| E

    %% Click Events
    click B "https://github.com/qtvo93/web-dev-app-pern/tree/main/todo/"
    click D "https://github.com/qtvo93/web-dev-app-pern/tree/main/back-end/"
    click H "https://github.com/qtvo93/web-dev-app-pern/blob/main/back-end/renders/auth.js"
    click I "https://github.com/qtvo93/web-dev-app-pern/blob/main/back-end/renders/dashboard.js"
    click G "https://github.com/qtvo93/web-dev-app-pern/blob/main/back-end/validations/authorize.js"
    click F "https://github.com/qtvo93/web-dev-app-pern/blob/main/back-end/validations/serverValidation.js"
    click E "https://github.com/qtvo93/web-dev-app-pern/tree/main/back-end/Dockerfile"
    click C "https://github.com/qtvo93/web-dev-app-pern/tree/main/todo/Dockerfile"
    click K "https://github.com/qtvo93/web-dev-app-pern/blob/main/docker-compose.yml"

    %% Styles
    classDef browser fill:#ffeb3b,stroke:#333,stroke-width:2px;
    classDef frontend fill:#a0d2eb,stroke:#333,stroke-width:2px;
    classDef backend fill:#90caf9,stroke:#333,stroke-width:2px;
    classDef database fill:#c8e6c9,stroke:#333,stroke-width:2px;
    classDef docker fill:#ffcc80,stroke:#333,stroke-width:2px;
    classDef compose fill:#d1c4e9,stroke:#333,stroke-width:2px;
```
