# jahnu05/ad-sphere architecture

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

- Interactive diagram: https://gitdiagram.com/jahnu05/ad-sphere
- Repository: https://github.com/jahnu05/ad-sphere

## Overview

##### Frontend (in the "frontend" directory) – A React-based client-side application.
2. Backend (in the "server" directory) – A Node.js/Express server with models, routes, and supporting utilities.

##### Main Components
- Frontend Client: The React application (located in the "frontend" folder) handles user interaction, routing, and rendering of various pages/components (e.g., HomePage, Login, SignUp, multiple dashboards such as AdminHome, AdvertiserHome, etc.).
- Backend Server: The Node.js/Express server (located in the "server" folder) is responsible for handling API requests, interacting with data models (advertisment, customer, question, response, and user), and serving JSON data or processing form submissions.
- Database / Data Source: Although an explicit database isn’t mentioned, the presence of data files (for example in "server/data/relatedCategories.json") and the defined models suggest that a database (or at least a persistent data layer) is involved.
- External Services & Utilities: There are utility functions and possible integrations with other services (for example using nodemon for development, external modules listed in package.json files, etc.).

##### Analyzing the File Structure
- The "frontend" directory contains the complete React application with its own README, configuration files, public assets (index.html, manifest, etc.), and a "src" folder that includes pages, components, stylesheets, and dashboard-specific files.
- The "server" directory contains:
- “models”: JavaScript files that define the data schema for entities like advertisement, customer, etc.
- “routes”: API endpoints for handling advertisements, forms, and user authentication.
- "utils": Utility scripts (such as mapOrders.js and utils.js) for supporting different functionalities.
- "data" and "images": Additional resources that the backend may serve or use.
- “server.js”: Likely the entry point that sets up the Express server and connects all parts.
- There are separate package.json and package-lock.json files for both frontend and server, indicating independent dependency management and build processes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend
    subgraph "Frontend"
        FE_Client["React Application"] 
        FE_HP["HomePage"]
        FE_Login["Login"]
        FE_SignUp["SignUp"]
        subgraph "Dashboards"
            FE_AdminHome["AdminHome"]
            FE_AdvertiserHome["AdvertiserHome"]
            FE_LogisticsHome["LogisticsHome"]
        end
        FE_Header["Header"]
        FE_FormBuilder["Form Builder"]
    end

    %% Backend
    subgraph "Backend"
        B_Server["Express Server (server.js)"]
        subgraph "API Routes"
            B_adRoutes["Advertisement Routes"]
            B_formRoutes["Form Routes"]
            B_userAuth["User Authentication Routes"]
        end
        subgraph "Models"
            B_Advertisment["Advertisment Model"]
            B_Customer["Customer Model"]
            B_Question["Question Model"]
            B_Response["Response Model"]
            B_User["User Model"]
        end
        subgraph "Utilities"
            B_MapOrders["Map Orders Utility"]
            B_Utilities["Additional Utilities"]
        end
        B_Data["Related Categories (JSON Data)"]
    end

    %% Frontend to Backend API interactions
    FE_HP -->|"fetchSession"| B_userAuth
    FE_Login -->|"authCall"| B_userAuth
    FE_SignUp -->|"authCall"| B_userAuth
    FE_AdminHome -->|"fetchAds"| B_adRoutes
    FE_AdvertiserHome -->|"fetchAds"| B_adRoutes
    FE_LogisticsHome -->|"fetchForms"| B_formRoutes
    FE_FormBuilder -->|"formSubmission"| B_formRoutes

    %% Backend internal interactions
    B_Server --> B_adRoutes
    B_Server --> B_formRoutes
    B_Server --> B_userAuth
    B_Server --> B_Data

    B_adRoutes -->|"usesModel"| B_Advertisment
    B_adRoutes -->|"usesModel"| B_Customer

    B_formRoutes -->|"usesModel"| B_Question
    B_formRoutes -->|"usesModel"| B_Response
    B_formRoutes -->|"utilizes"| B_MapOrders

    B_userAuth -->|"usesModel"| B_User
    B_userAuth -->|"utilizes"| B_Utilities

    %% Click Events for Frontend
    click FE_Client "https://github.com/jahnu05/ad-sphere/tree/main/frontend/"
    click FE_HP "https://github.com/jahnu05/ad-sphere/blob/main/frontend/src/HomePage.js"
    click FE_Login "https://github.com/jahnu05/ad-sphere/blob/main/frontend/src/Login.js"
    click FE_SignUp "https://github.com/jahnu05/ad-sphere/blob/main/frontend/src/SignUp.js"
    click FE_AdminHome "https://github.com/jahnu05/ad-sphere/blob/main/frontend/src/Dashboards/AdminHome.js"
    click FE_AdvertiserHome "https://github.com/jahnu05/ad-sphere/blob/main/frontend/src/Dashboards/AdvertiserHome.js"
    click FE_LogisticsHome "https://github.com/jahnu05/ad-sphere/blob/main/frontend/src/Dashboards/LogisticsHome.js"
    click FE_Header "https://github.com/jahnu05/ad-sphere/blob/main/frontend/src/Components/Header.js"
    click FE_FormBuilder "https://github.com/jahnu05/ad-sphere/blob/main/frontend/src/FormBuilder.js"

    %% Click Events for Backend
    click B_Server "https://github.com/jahnu05/ad-sphere/blob/main/server/server.js"
    click B_Advertisment "https://github.com/jahnu05/ad-sphere/blob/main/server/models/advertisment.js"
    click B_Customer "https://github.com/jahnu05/ad-sphere/blob/main/server/models/customer.js"
    click B_Question "https://github.com/jahnu05/ad-sphere/blob/main/server/models/question.js"
    click B_Response "https://github.com/jahnu05/ad-sphere/blob/main/server/models/response.js"
    click B_User "https://github.com/jahnu05/ad-sphere/blob/main/server/models/user.js"
    click B_adRoutes "https://github.com/jahnu05/ad-sphere/blob/main/server/routes/adRoutes.js"
    click B_formRoutes "https://github.com/jahnu05/ad-sphere/blob/main/server/routes/formRoutes.js"
    click B_userAuth "https://github.com/jahnu05/ad-sphere/blob/main/server/routes/userAuth.js"
    click B_Data "https://github.com/jahnu05/ad-sphere/blob/main/server/data/relatedCategories.json"
    click B_MapOrders "https://github.com/jahnu05/ad-sphere/blob/main/server/utils/mapOrders.js"
    click B_Utilities "https://github.com/jahnu05/ad-sphere/blob/main/server/utils/utils.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef route fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef model fill:#fde2e2,stroke:#c0392b,stroke-width:2px;
    classDef utility fill:#fef9e7,stroke:#f1c40f,stroke-width:2px;
    classDef data fill:#e2e3e5,stroke:#818182,stroke-width:2px;

    %% Assign classes for Frontend nodes
    class FE_Client,FE_HP,FE_Login,FE_SignUp,FE_AdminHome,FE_AdvertiserHome,FE_LogisticsHome,FE_Header,FE_FormBuilder frontend;

    %% Assign classes for Backend nodes
    class B_Server backend;
    class B_adRoutes,B_formRoutes,B_userAuth route;
    class B_Advertisment,B_Customer,B_Question,B_Response,B_User model;
    class B_MapOrders,B_Utilities utility;
    class B_Data data;
```
