# ahmedhamdiy/sanay3yonthego architecture

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

- Interactive diagram: https://gitdiagram.com/ahmedhamdiy/sanay3yonthego
- Repository: https://github.com/ahmedhamdiy/sanay3yonthego

## Overview

##### Project Type & Purpose
- This is a full-stack service network application built using the PERN stack (PostgreSQL, Express.js, React, Node.js). It enables three primary user classes (Customers, Technicians, and Admins) to interact with the system.
- The project allows customers to request technician services, technicians to manage and respond to orders, and admins to oversee operations and manage issues like complaints and feedback.

##### Main Components
a. Client (Frontend):
- The Client folder holds a React application that is subdivided into separate views based on user roles:
- AdminView: Contains components, routes, and styles for admin functionalities (e.g., AdminAccount, NavBarAdmin, service management pages).
- CustView: Contains routes and components for customers (e.g., AccountDetails, OrderList, ComplaintForm, review and feedback interfaces).
- TechView: Contains components and routes tailored for technicians (e.g., OrdersList, UploadOffer, Profile, ratings, etc.).
- UserView: Handles user login and profile management.

b. Server (Backend):
- The Server folder contains the Node.js/Express server.
- Key subcomponents include:
- Configuration (e.g., DB.js to connect to PostgreSQL).
- Controllers: Divided into general controllers (OrderController, UserController) and “minor” controllers handling specific domains such as Bundles, Complaints, Feedback, Notifications, Offers, Rewards, and Services.
- Routes: Organized similarly with separate route definitions for “minor” endpoints and dedicated routes for orders and user management.
- Helpers: Utility functions (e.g., GenHelper.js) that support various controller operations.
- It’s important to show how these controllers and routes form the server’s API layer that handles HTTP requests from the client.

c. Database:
- PostgreSQL database (created using the CreateDB.sql script) which stores persistent data for users, orders, complaints, feedback, and possibly technician work details.

##### Relationships and Interactions
- The server processes incoming requests through its controllers and routes, interacts with the PostgreSQL database to execute queries or store data, and then sends responses back to the client.

##### Architectural Patterns and Design Principles
- Separation of concerns:
- Frontend separates concern via multiple view modules (AdminView, CustView, TechView, etc.) offering role-based interfaces.
- Backend is modularized into controllers, routes, and configuration.
- RESTful API-based communication between Client and Server.
- Layered architecture: Presentation layer (React UI) → Business Logic/API layer (Express controllers/routes) → Data layer (PostgreSQL).

##### Additional Details
- Data flow that begins at the user interface, passes through API endpoints, and ends with database operations, then is returned back as application responses.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Frontend (React Application)"
        Client["Client (React App)"]:::client
        AdminView["Admin View"]:::client
        CustView["Customer View"]:::client
        TechView["Technician View"]:::client
        UserView["User View"]:::client
    end

    subgraph "Backend (Express Server)"
        ExpressServer["Express Server"]:::backend
        DBConfig["DB Config (PostgreSQL)"]:::backend
        OrderController["OrderController"]:::backend
        UserController["UserController"]:::backend
        MinorControllers["Minor Controllers"]:::backend
        Helpers["GenHelper.js"]:::backend
        OrderRoutes["Order Routes"]:::backend
        UserRoutes["User Routes"]:::backend
        MinorRoutes["Minor Routes"]:::backend
    end

    Database["PostgreSQL DB"]:::database
    CreateDB["CreateDB.sql"]:::database

    %% Frontend to Backend Communication
    AdminView -->|"HTTPRequestResponse"| ExpressServer
    CustView -->|"HTTPRequestResponse"| ExpressServer
    TechView -->|"HTTPRequestResponse"| ExpressServer
    UserView -->|"HTTPRequestResponse"| ExpressServer

    %% Backend Internal Interactions
    ExpressServer -->|"uses"| DBConfig
    DBConfig -->|"connects"| Database

    ExpressServer -->|"calls"| OrderController
    ExpressServer -->|"calls"| UserController
    ExpressServer -->|"calls"| MinorControllers
    ExpressServer -->|"uses"| Helpers

    ExpressServer -->|"routesTo"| OrderRoutes
    ExpressServer -->|"routesTo"| UserRoutes
    ExpressServer -->|"routesTo"| MinorRoutes

    OrderRoutes -->|"mapsTo"| OrderController
    UserRoutes -->|"mapsTo"| UserController
    MinorRoutes -->|"mapsTo"| MinorControllers

    %% Click Events for Component Mapping
    click Client "https://github.com/ahmedhamdiy/sanay3yonthego/tree/main/Client/sanay3y-on-the-go"
    click AdminView "https://github.com/ahmedhamdiy/sanay3yonthego/tree/main/Client/sanay3y-on-the-go/src/AdminView"
    click CustView "https://github.com/ahmedhamdiy/sanay3yonthego/tree/main/Client/sanay3y-on-the-go/src/CustView"
    click TechView "https://github.com/ahmedhamdiy/sanay3yonthego/tree/main/Client/sanay3y-on-the-go/src/TechView"
    click UserView "https://github.com/ahmedhamdiy/sanay3yonthego/tree/main/Client/sanay3y-on-the-go/src/UserView"
    click ExpressServer "https://github.com/ahmedhamdiy/sanay3yonthego/blob/main/Server/server.js"
    click DBConfig "https://github.com/ahmedhamdiy/sanay3yonthego/blob/main/Server/Config/DB.js"
    click OrderController "https://github.com/ahmedhamdiy/sanay3yonthego/blob/main/Server/Controllers/OrderController.js"
    click UserController "https://github.com/ahmedhamdiy/sanay3yonthego/blob/main/Server/Controllers/UserController.js"
    click MinorControllers "https://github.com/ahmedhamdiy/sanay3yonthego/tree/main/Server/Controllers/Minor"
    click Helpers "https://github.com/ahmedhamdiy/sanay3yonthego/blob/main/Server/Helpers/GenHelper.js"
    click OrderRoutes "https://github.com/ahmedhamdiy/sanay3yonthego/blob/main/Server/Routes/Order.js"
    click UserRoutes "https://github.com/ahmedhamdiy/sanay3yonthego/blob/main/Server/Routes/User.js"
    click MinorRoutes "https://github.com/ahmedhamdiy/sanay3yonthego/tree/main/Server/Routes/Minor"
    click CreateDB "https://github.com/ahmedhamdiy/sanay3yonthego/blob/main/CreateDB.sql"

    %% Styles
    classDef client fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef backend fill:#ABEBC6,stroke:#229954,stroke-width:2px;
    classDef database fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
```
