# elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system architecture

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

- Interactive diagram: https://gitdiagram.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system
- Repository: https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system

## Overview

##### Main components
- Client/Vehicle Side: Represents the thin client (on-board the vehicle) capturing image data and sending it to the server.
- API / Server (app.py): Acts as the central entry point, receiving data, routing requests, and coordinating the processing pipelines.
– DETR (object detection)
– GLPN (depth estimation)
– LSTM (historical data prediction)
- Data Storage & Configuration:
– The “data” directory holds pre-trained models and scaling objects.
– “config.py” is present for system-wide configuration settings.
- Utilities and Extensions:
– “utils” for JSON output formatting, Cython-based processing optimizations, and visualizations.
- Training & Testing Components:
– “trainings_tests” contains Jupyter notebooks and test data for model training, evaluation, and refining dataset pipelines.
- Deployment:
– The Dockerfile and configuration files (.idea, .vscode) point to containerization and development environment settings.

##### Relationships and data flow
- The server, upon receiving data, dispatches the image data to the different model modules:
– First, detected objects can be obtained from the DETR module.
– Then, depth estimation via the GLPN module.
– And finally, historical trajectory or prediction through the LSTM module.
- The configuration (config.py) should be shown as providing runtime settings that influence one or more of the modules.
- Utilities (under utils) should be depicted as auxiliary services employed by the server for data formatting, visualization, or optimized processing (via Cython).

##### Important architectural patterns/design principles
- Client-Server Architecture: Highlight the separation between the thin client (vehicle) and the cloud-based processing system.
- Modular Model Processing: Clearly separate individual processing blocks (DETR, GLPN, LSTM) to emphasize independent responsibilities and easier testing/updating.
- Data Pipeline & Integration: Indicate data ingestion, pre-processing (e.g., scaling using the models in the “data” folder), and post-processing (JSON output via utils/JSON_output.py or visualization).
- Containerization: Mark where Docker is involved, suggesting that the entire server (and perhaps training sessions) might run within containerized environments for scalability and consistency.

- Legends or annotations that explain each component’s role and the technologies involved (mention of PyTorch for LSTM/deep learning models, XGBoost for potential additional modeling, Cython for performance optimizations, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client Device"]:::client

    subgraph "Docker Container"
        subgraph "API & Processing Modules"
            B["API Server (app.py)"]:::server
            F["Configuration Module (config.py)"]:::config
            G["Data/Model Storage"]:::storage
            C["Object Detection Module (DETR)"]:::module
            D["Depth Estimation Module (GLPN)"]:::module
            E["Temporal Prediction Module (LSTM)"]:::module
            E1["LSTM Prediction Details"]:::module
        end
        subgraph "Utility Services"
            H["JSON Formatter"]:::utility
            I["Visualization"]:::utility
            J["Cython Processing"]:::utility
        end
    end

    K["Training & Testing Pipelines"]:::training
    L["Deployment (Dockerfile)"]:::deployment

    %% Data Flow
    A -->|"HTTP_Request"| B
    B -->|"dispatch"| C
    B -->|"dispatch"| D
    B -->|"dispatch"| E
    C -->|"detection_results"| D
    D -->|"depth_info"| E
    E -->|"prediction"| A

    %% Configuration & Data Flow to Modules
    F --> C
    F --> D
    F --> E
    G --> C
    G --> D
    G --> E

    %% Utility Services used by API Server
    B -->|"formats"| H
    B -->|"visualizes"| I
    B -->|"optimizes"| J

    %% Training Pipeline Connection
    K -->|"updates_models"| G

    %% Click Events
    click B "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/blob/main/app.py"
    click C "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/blob/main/models/detr_model.py"
    click D "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/blob/main/models/glpn_model.py"
    click E "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/blob/main/models/lstm_model.py"
    click E1 "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/blob/main/models/predict_z_location_single_row_lstm.py"
    click F "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/blob/main/config.py"
    click G "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/tree/main/data/models"
    click H "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/blob/main/utils/JSON_output.py"
    click I "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/blob/main/utils/visualization.py"
    click J "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/blob/main/utils/processing.pyx"
    click K "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/tree/main/trainings_tests"
    click L "https://github.com/elfilaoussama/advanced_driver_vision_assistance_with_near_collision_estimation_system/tree/main/Dockerfile"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef server fill:#87CEEB,stroke:#000,stroke-width:1px;
    classDef module fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef config fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef storage fill:#D8BFD8,stroke:#000,stroke-width:1px;
    classDef utility fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef training fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef deployment fill:#D3D3D3,stroke:#000,stroke-width:1px;
```
