# shoyers/projet-tuteure architecture

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

- Interactive diagram: https://gitdiagram.com/shoyers/projet-tuteure
- Repository: https://github.com/shoyers/projet-tuteure

## Overview

##### Main Components
- Application Entry Point: Represent main.py (and possibly src/app.py as the application’s initializer or router).
- Configuration: The config directory (config/settings.py) that holds database and other settings.
- Controllers: Under src/controllers (dashboard_controller.py, settings_controller.py, table_controller.py) that handle incoming requests and drive the application logic.
- Models: In src/models (sensor.py, sensor_data.py) managing sensor data representation.
- Views: Represented in src/views (dashboard_view.py, settings_view.py, tables_view.py, and components under src/views/components) that build the graphical interface. Also include the public assets (images/fonts) under src/public.
- Services: The business logic layer in src/services (e.g., sensor_service.py) handling sensor-specific operations.
- Database Layer: The database directory under src/database containing connection.py and query_manager.py, which interface with a MySQL database (as mentioned in the README).
- Utility Functions: The utils directory (e.g., console_redirector.py, helpers.py) that supports logging or common functionality.
- SQL Schema: The sensor_schemas_simple.sql file to show the initial database schema for sensor data.

##### Relationships and Interactions
- The entry point (main.py) initializes the application (possibly through src/app.py) and sets up routing to controllers.
- Controllers interact with models, services, and views to process user requests and render the user interface.
- The service layer (sensor_service.py) encapsulates the business logic around sensor data, interfacing with database components (src/database/connection.py and query_manager.py) using configuration settings from config/settings.py.
- Views and components combine front-end assets with data provided by controllers, ensuring the dashboard reflects real-time sensor updates.
- Utility modules provide supporting functionality to different layers.

##### Architectural Patterns and Design Principles
- MVC-Like Pattern: Clearly segregating controllers (handling input and logic), models (data structure), and views (user interface).
- Layered Architecture: Separation of concerns with distinct layers for configuration, services, database access, and utilities.
- Modularization: Each component (controllers, models, views, services) is structured in its own directory for clarity and maintainability.
- External Configuration: Using a dedicated configuration file (config/settings.py) to manage environment-specific settings like MySQL connection details.

##### Technologies and Framework Components
- Python is the core language with dependency management via requirements.txt.
- MySQL as the database for persisting sensor data.
- Likely use of a web framework (even if it is a lightweight or custom one) given the MVC structure, though the framework is not explicitly named.
- Static assets such as fonts and images are stored under src/public for the UI.
- SQL file sensor_schemas_simple.sql provides the schema for database initiation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application Entry"
        mainPY["main.py"]:::entry
        appPY["src/app.py"]:::entry
    end
    subgraph "Business Logic Layer"
        subgraph "Controllers"
            dashController["dashboard_controller.py"]:::controller
            settingsController["settings_controller.py"]:::controller
            tableController["table_controller.py"]:::controller
        end
        sensorService["sensor_service.py"]:::service
    end
    subgraph "Data Access Layer"
        subgraph "Models"
            sensorModel["sensor.py"]:::model
            sensorDataModel["sensor_data.py"]:::model
        end
        subgraph "Database Access"
            dbConnection["connection.py"]:::database
            queryManager["query_manager.py"]:::database
            mysqlDB["MySQL Database"]:::database
        end
    end
    subgraph "Presentation Layer"
        subgraph "Views"
            dashView["dashboard_view.py"]:::view
            settingsView["settings_view.py"]:::view
            tablesView["tables_view.py"]:::view
        end
        publicAssets["Public Assets"]:::view
    end
    subgraph "Configuration & Utilities"
        configSettings["config/settings.py"]:::config
        subgraph "Utilities"
            consoleRedirector["console_redirector.py"]:::utility
            helpers["helpers.py"]:::utility
        end
    end
    sqlSchema["sensor_schemas_simple.sql"]:::schema

    %% Connections from Application Entry to Controllers
    mainPY --> appPY
    appPY --> dashController
    appPY --> settingsController
    appPY --> tableController

    %% Controllers invoking service layer
    dashController -->|"calls"| sensorService
    settingsController -->|"calls"| sensorService
    tableController -->|"calls"| sensorService

    %% Controllers to Views
    dashController -->|"renders"| dashView
    settingsController -->|"renders"| settingsView
    tableController -->|"renders"| tablesView

    %% Service interacting with Models and Database
    sensorService -->|"processes"| sensorModel
    sensorService -->|"processes"| sensorDataModel
    sensorService -->|"queries"| dbConnection
    sensorService -->|"queries"| queryManager

    %% Database Access to Physical Database and Schema
    dbConnection -->|"connects"| mysqlDB
    queryManager -->|"executes"| mysqlDB
    sqlSchema -->|"initSchema"| mysqlDB

    %% Service feeding real-time data to Views
    sensorService -->|"LiveFeed"| dashView

    %% Views using Public Assets
    dashView -->|"assets"| publicAssets
    settingsView -->|"assets"| publicAssets
    tablesView -->|"assets"| publicAssets

    %% Configuration influences Service and Database
    configSettings -->|"configures"| sensorService
    configSettings -->|"DBconfig"| dbConnection

    %% Utility support for controllers
    dashController -->|"utilizes"| helpers
    settingsController -->|"utilizes"| consoleRedirector

    %% Click Events
    click mainPY "https://github.com/shoyers/projet-tuteure/blob/main/main.py"
    click appPY "https://github.com/shoyers/projet-tuteure/blob/main/src/app.py"
    click dashController "https://github.com/shoyers/projet-tuteure/blob/main/src/controllers/dashboard_controller.py"
    click settingsController "https://github.com/shoyers/projet-tuteure/blob/main/src/controllers/settings_controller.py"
    click tableController "https://github.com/shoyers/projet-tuteure/blob/main/src/controllers/table_controller.py"
    click sensorService "https://github.com/shoyers/projet-tuteure/blob/main/src/services/sensor_service.py"
    click sensorModel "https://github.com/shoyers/projet-tuteure/blob/main/src/models/sensor.py"
    click sensorDataModel "https://github.com/shoyers/projet-tuteure/blob/main/src/models/sensor_data.py"
    click dbConnection "https://github.com/shoyers/projet-tuteure/blob/main/src/database/connection.py"
    click queryManager "https://github.com/shoyers/projet-tuteure/blob/main/src/database/query_manager.py"
    click dashView "https://github.com/shoyers/projet-tuteure/blob/main/src/views/dashboard_view.py"
    click settingsView "https://github.com/shoyers/projet-tuteure/blob/main/src/views/settings_view.py"
    click tablesView "https://github.com/shoyers/projet-tuteure/blob/main/src/views/tables_view.py"
    click publicAssets "https://github.com/shoyers/projet-tuteure/tree/main/src/public"
    click configSettings "https://github.com/shoyers/projet-tuteure/blob/main/config/settings.py"
    click consoleRedirector "https://github.com/shoyers/projet-tuteure/blob/main/src/utils/console_redirector.py"
    click helpers "https://github.com/shoyers/projet-tuteure/blob/main/src/utils/helpers.py"
    click sqlSchema "https://github.com/shoyers/projet-tuteure/blob/main/sensor_schemas_simple.sql"

    %% Style Classes
    classDef entry fill:#D1E8FF,stroke:#1F78C1,stroke-width:2px;
    classDef controller fill:#FFE0B2,stroke:#FB8C00,stroke-width:2px;
    classDef service fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef model fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef database fill:#FFCDD2,stroke:#D32F2F,stroke-width:2px;
    classDef view fill:#D1C4E9,stroke:#7B1FA2,stroke-width:2px;
    classDef config fill:#F0F4C3,stroke:#9E9D24,stroke-width:2px;
    classDef utility fill:#B2EBF2,stroke:#00796B,stroke-width:2px;
    classDef schema fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
```
