# paulcode2/hirafic-project architecture

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

- Interactive diagram: https://gitdiagram.com/paulcode2/hirafic-project
- Repository: https://github.com/paulcode2/hirafic-project

## Overview

##### Main Components
- Frontend Client: This is built with React and resides in the “Client” folder. Its components (views, pages, UI elements, hooks, assets) handle the user interface, client routing, state management, and API interactions (e.g., via Axios).
- Backend API: The backend is built with Flask. It contains modules like models (SQLAlchemy ORM for artisan, booking, client, user, report), routes (for authentication, artisan operations, booking, and client functionalities), forms, and utility modules (e.g., email_service).
- Database: The project uses an SQL database managed via Flask-SQLAlchemy and Alembic migrations. Though the specific DB isn’t mentioned, this layer is central to storing user profiles, booking data, and artisan details.
- Caching / Auxiliary Services: A Redis server is used (as per README instructions) for caching purposes. Also include email notification (via a dedicated email service module) and any real-time notification mechanisms.
- External Dependencies: Consider representing additional libraries/frameworks (like pycodestyle for quality, Axios for HTTP communication) as notes or external dependencies linked to their respective components.

##### Relationships and Interactions
- The Authentication module (JWT) should be shown as a part or overlay of the backend, with secure tokens passed between the Frontend and Backend.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly separate frontend and backend components since both live as independent clients communicating over HTTP.
- MVC or Layered Architecture: Inside the backend, illustrate the model layer (SQLAlchemy models), the controller/routes, and (if applicable) the view templating or API output layer.
- Security Best Practices: Emphasize JWT-based authentication, as well as secure communication between components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend (React)"
        FE["Client UI"]:::frontend
        FE1["Navigation"]:::frontend
        FE2["Booking Interface"]:::frontend
        FE3["Search"]:::frontend
        FE4["Profile Pages"]:::frontend
        FE5["Map/List Views"]:::frontend
        FE --> FE1
        FE --> FE2
        FE --> FE3
        FE --> FE4
        FE --> FE5
    end

    %% Backend Subgraph
    subgraph "Backend (Flask REST API)"
        BE_API["Backend API"]:::backend
        RC["Routes/Controllers"]:::backend
        MOD["Models"]:::backend
        FORM["Forms"]:::backend
        MIG["Migrations"]:::backend
        EXT["Extensions"]:::backend
        AUTH["Authentication (JWT)"]:::backend
        BE_API --> RC
        RC --> MOD
        RC --> FORM
        RC --> AUTH
    end

    %% Auxiliary Services Subgraph
    subgraph "Auxiliary Services"
        DB["Database (SQL)"]:::database
        REDIS["Redis Cache"]:::cache
        EMAIL["Email Notification Service"]:::service
    end

    %% Interconnections between Subgraphs
    FE -->|"API_Calls"| RC
    RC -->|"DB_RW"| DB
    RC <-->|"Cache_Access"| REDIS
    RC -->|"Notify"| EMAIL
    EXT -->|"DB_Config"| DB

    %% Click Events
    click FE "https://github.com/paulcode2/hirafic-project/tree/main/Client"
    click BE_API "https://github.com/paulcode2/hirafic-project/tree/main/backend"
    click RC "https://github.com/paulcode2/hirafic-project/tree/main/backend/routes"
    click MOD "https://github.com/paulcode2/hirafic-project/tree/main/backend/models"
    click FORM "https://github.com/paulcode2/hirafic-project/tree/main/backend/forms"
    click MIG "https://github.com/paulcode2/hirafic-project/tree/main/backend/migrations"
    click EXT "https://github.com/paulcode2/hirafic-project/blob/main/backend/extensions.py"
    click AUTH "https://github.com/paulcode2/hirafic-project/blob/main/backend/routes/auth.py"
    click EMAIL "https://github.com/paulcode2/hirafic-project/blob/main/backend/utils/email_service.py"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef cache fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef service fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
