# eseo-bigdata/bigdata_projet architecture

> Architecture diagram of the GitHub repository eseo-bigdata/bigdata_projet, 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/eseo-bigdata/bigdata_projet
- Repository: https://github.com/eseo-bigdata/bigdata_projet

## Overview

##### Main Components
- Front-end Application:
- “frontend” folder with its assets (HTML, CSS in main.css, JavaScript logic in index.js, and the various pages like About, BornesMap, Home, and Statistiques).
- That the front-end is responsible for interactive visualizations (using Leaflet for the map, Chart.js, or D3.js for charts, etc.) and communicates with the back-end via API calls.
- Back-end Server:
- “src” directory as a Node.js/Express application.
- Sub-components inside:
- Controllers (e.g., bornesController.js, nbVehiculesRegionController.js, etc.) — these handle data processing and business logic.
- Models (e.g., BorneElectrique.js, Region.js, etc.) — show that these are Mongoose schemas defining MongoDB collections.
- Routes (organized in the “src/routes” folder) — these define the API endpoints and map incoming requests to the controllers.
- Database Connector (the “src/db/connexion.js”) — responsible for establishing the connection with the MongoDB Atlas instance.
- Utilities such as the responseFormatter — these manage consistent formatting of API responses.
- Database:
- External MongoDB Atlas instance that stores the seven main collections (BornesElectriques, NbVehiculesParRegion, Region, NbVehiculesParCommune, DepartementEtRegion, BornesCommuneDepartementRegion, and PointsdeCharge).

##### Relationships and Data Flow
- From the Back-end “Routes” layer, indicate that requests are forwarded to the appropriate “Controller”, which then leverages a specific “Model” to query or update the MongoDB database.
- If applicable, note any middleware (e.g., express.json, cors, dotenv for env variables) that processes HTTP requests before they reach controllers.

##### Architectural Patterns and Design Principles
- MVC (Model-View-Controller) pattern inherent in the back-end:
- MVC is reflected in the clear separation between “controllers”, “models”, and “routes”.
- Modular and maintainable design through the organization of concerns (API endpoints, business logic, database abstraction).
- Loose coupling between the client and server, as the front-end consumes REST API endpoints.

##### Relevant Technologies and Frameworks
- Front-end:
- HTML/CSS/JavaScript (vanilla or lightweight frameworks). Mention use of webpack (frontend/webpack.config.js), as well as libraries such as Leaflet for maps and Chart.js or D3.js for analytics.
- Back-end:
- Node.js and Express for building the server.
- Mongoose for MongoDB object modeling.
- dotenv for managing environment variables.
- Database:
- MongoDB Atlas, with its seven well-structured collections for different datasets.

##### Additional Details
- Keep in mind the deployment target is localhost for now; you might illustrate that this system is currently in a local/testing environment which could be extended later.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FA("Frontend Application"):::frontend
        F1("index.html"):::asset
        F2("main.css"):::asset
        F3("index.js"):::asset
        subgraph "Pages"
            P1("About.js"):::asset
            P2("BornesMap.js"):::asset
            P3("Home.js"):::asset
            P4("Statistiques.js"):::asset
        end
    end

    %% Back-end Layer
    subgraph "Back-end Layer"
        BS("Express Server"):::backend
        RT("Routes"):::backend
        CT("Controllers"):::backend
        MD("Models"):::backend
        DC("Database Connector"):::backend
        RF("Response Formatter"):::backend
    end

    %% External Database
    DB("MongoDB Atlas"):::database

    %% Data Flow Connections
    FA -->|"APIcalls"| BS
    BS -->|"handles"| RT
    RT -->|"delegates"| CT
    CT -->|"uses"| MD
    MD -->|"queries"| DB
    DB -->|"responds"| MD
    MD -->|"sendsData"| CT
    CT -->|"formats"| RF
    RF -->|"response"| BS
    BS -->|"servesData"| FA
    BS -->|"connects"| DC
    DC -->|"establishesConn"| DB

    %% Click Events for Frontend
    click FA "https://github.com/eseo-bigdata/bigdata_projet/tree/main/frontend"
    click F1 "https://github.com/eseo-bigdata/bigdata_projet/blob/main/frontend/index.html"
    click F2 "https://github.com/eseo-bigdata/bigdata_projet/blob/main/frontend/src/assets/styles/main.css"
    click F3 "https://github.com/eseo-bigdata/bigdata_projet/blob/main/frontend/src/index.js"
    click P1 "https://github.com/eseo-bigdata/bigdata_projet/blob/main/frontend/src/pages/About.js"
    click P2 "https://github.com/eseo-bigdata/bigdata_projet/blob/main/frontend/src/pages/BornesMap.js"
    click P3 "https://github.com/eseo-bigdata/bigdata_projet/blob/main/frontend/src/pages/Home.js"
    click P4 "https://github.com/eseo-bigdata/bigdata_projet/blob/main/frontend/src/pages/Statistiques.js"

    %% Click Events for Back-end
    click BS "https://github.com/eseo-bigdata/bigdata_projet/blob/main/src/server.js"
    click CT "https://github.com/eseo-bigdata/bigdata_projet/tree/main/src/controllers"
    click MD "https://github.com/eseo-bigdata/bigdata_projet/tree/main/src/models"
    click RT "https://github.com/eseo-bigdata/bigdata_projet/tree/main/src/routes"
    click DC "https://github.com/eseo-bigdata/bigdata_projet/blob/main/src/db/connexion.js"
    click RF "https://github.com/eseo-bigdata/bigdata_projet/blob/main/src/utils/responseFormatter.js"

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