# sdave0/fullstack_crud architecture

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

- Interactive diagram: https://gitdiagram.com/sdave0/fullstack_crud
- Repository: https://github.com/sdave0/fullstack_crud

## Overview

##### Main Components
- Frontend: This is the Next.js-based application found in the “frontend” directory. It includes pages, UI components, styles, configuration files, and Next.js–specific Docker files.
- Backend: Although the README refers to it as “backend,” the file tree places it under the “main” directory. Here you have the Flask application with files like app.py, auth_routes.py, user_routes.py, models.py, and user_repository.py.
- Database: PostgreSQL acts as the persistent storage backend. Although its configuration details (like connection strings) are mentioned in environment variables, it is a key component in the architecture.
- Containerization/Orchestration: Docker Compose (compose.yml, docker-compose file in the README) orchestrates the containers for the frontend, backend, and database.
- Additional Components: External services such as any third-party API integrations (if applicable) and CI/CD pipelines (GitHub Workflows) can also be depicted.

##### Relationships and Interactions
- Frontend ⇄ Backend: The Next.js frontend communicates with the Flask backend via RESTful API calls. For example, the frontend calls endpoints for authentication (register, login, get current user) and CRUD operations on user data.
- Backend ⇄ Database: The Flask service connects to the PostgreSQL database to perform queries and manage user data. This includes handling secure authentication using JWT and performing CRUD operations.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The architecture clearly separates the concerns of the user interface (Next.js) and the application logic/data management (Flask), which promotes maintainability and scalability.
- Containerization: Use Docker to encapsulate and isolate the various components. This helps in reliable deployments and consistency across environments.

##### Incorporate Relevant Technologies and Tools
- Frontend: Next.js, React, Tailwind CSS
- Backend: Flask, Python, JWT for secure token management
- Database: PostgreSQL (with environment variables provided for configuration)
- Containerization: Docker (with separate Dockerfiles for frontend and backend) and Docker Compose for orchestration
- CI/CD: GitHub Workflows for continuous integration

##### Specific Elements
- From the Backend to the Database: show database queries and updates.
- Another set for infrastructure components (database, Docker environment).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Next.js Frontend"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Flask Backend"]:::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["PostgreSQL Database"]:::database
    end

    %% Containerization & Orchestration
    subgraph "Containerization & Orchestration"
        DC["Docker Compose Orchestrator"]:::orchestration
        FD["Next.js Dockerfile"]:::orchestration
        BD["Flask Dockerfile"]:::orchestration
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        CI["GitHub Workflows"]:::cicd
    end

    %% Connections
    FE -->|"REST_API_calls"| BE
    BE -->|"Database_queries"| DB
    DC --> FE
    DC --> BE
    DC --> DB
    CI --> DC

    %% Click events
    click FE "https://github.com/sdave0/fullstack_crud/tree/master/frontend/"
    click BE "https://github.com/sdave0/fullstack_crud/tree/master/main/"
    click DC "https://github.com/sdave0/fullstack_crud/blob/master/compose.yml"
    click FD "https://github.com/sdave0/fullstack_crud/blob/master/frontend/next.dockerfile"
    click BD "https://github.com/sdave0/fullstack_crud/blob/master/main/flask.dockerfile"
    click CI "https://github.com/sdave0/fullstack_crud/blob/master/.github/workflows/ci.yml"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef backend fill:#ffcdd2,stroke:#b71c1c,stroke-width:2px;
    classDef database fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef orchestration fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
    classDef cicd fill:#d1c4e9,stroke:#512da8,stroke-width:2px;
```
