# amueed/vehicle-monitoring architecture

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

- Interactive diagram: https://gitdiagram.com/amueed/vehicle-monitoring
- Repository: https://github.com/amueed/vehicle-monitoring

## Overview

##### Main Components
- Frontend:
- Built with React (using Vite) and Material UI.
- Contains source directories for components, pages (notably the VehiclesPage), assets, models (Customer.ts, Vehicle.ts), services (VehicleService.ts), and configuration.
- Configured to run separately (with its own Dockerfile and Nginx config) and served at http://localhost:4200.
- Backend:
- Built with .NET Core Minimal API surrounded by a layered architecture.
- Divided into distinct sub-projects:
▪ VehicleMonitoring.Api – Contains the API entry point (Program.cs) and configuration files (appsettings.json, Docker configuration).
▪ VehicleMonitoring.Core – Houses domain models (Customer, Vehicle, BaseEntity), application services (e.g., IVehicleStatusService) and defines the domain logic or contracts.
▪ VehicleMonitoring.Infrastructure – Implements data access via EF Core (MonitoringDbContext), generic repositories, and dependency injection setup. This layer also includes a DatabaseSeeder for populating initial data.
- Exposes endpoints and API documentation through Swagger at http://localhost:8080/swagger/index.html.
- Database:
- While no standalone database service file is explicitly listed, the EF Core DbContext (MonitoringDbContext.cs) indicates that a database (SQL Server or another provider) is connected to the backend.
- Docker and Orchestration:
- Docker-related files (Dockerfiles for backend and frontend, docker-compose.yaml) indicate that both components are containerized and managed by Docker Compose.

##### Component Relationships and Interactions
- The Frontend interacts with the Backend via RESTful API calls (using HTTP) to perform vehicle monitoring and customer operations.
- The Backend’s API layer accepts requests and delegates business logic calls to the Core (application services and domain models), then utilizes the Infrastructure layer for data persistence.
- The Infrastructure layer directly interacts with the database (via EF Core) to retrieve, update, or seed data.
- Docker Compose orchestrates both the frontend and backend containers ensuring that they can communicate as needed and are deployed efficiently.

##### Architectural Patterns and Design Principles
- Layered Architecture: The backend is clearly organized into presentation (API), business logic (Core with domain models and services), and data access (Infrastructure) layers.
- Minimal API: Used in .NET Core for a lean, concise entry point into the backend.
- Separation of Concerns: Different responsibilities are split across multiple projects/modules (standard .NET project structure).
- Containerization: Dockerfiles for each component provide isolation and ease of deployment and scaling.

- Infrastructure to a “Database” symbol.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Components
    subgraph "Frontend"
        FApp["Frontend (React/Vite) (http://localhost:4200)"]:::frontend
        FPage["VehiclesPage (Components & Pages)"]:::frontend
        FService["VehicleService"]:::frontend
    end

    %% Backend Layers
    subgraph "Backend"
        API["Backend API (.NET Core Minimal API) (http://localhost:8080)"]:::backend
        Domain["Domain Layer (VehicleMonitoring.Core)"]:::backend
        DataAccess["Data Access/Infrastructure (EF Core, Repositories)"]:::backend
    end

    %% Database
    DB["Database"]:::database

    %% Docker Orchestration
    Docker["Docker Compose & Dockerfiles"]:::docker

    %% Data flow connections
    FApp -->|"REST_API_calls"| API
    API -->|"Delegates_logic"| Domain
    API -->|"Uses_EFCore"| DataAccess
    DataAccess -->|"Interacts_with"| DB

    %% Frontend internal connections
    FApp --> FPage
    FApp --> FService

    %% Docker connects to primary containers
    Docker -->|"Orchestrates"| FApp
    Docker -->|"Orchestrates"| API

    %% Click Events for Component Mapping
    click FApp "https://github.com/amueed/vehicle-monitoring/tree/main/frontend/"
    click FPage "https://github.com/amueed/vehicle-monitoring/tree/main/frontend/src/pages/VehiclesPage/"
    click FService "https://github.com/amueed/vehicle-monitoring/blob/main/frontend/src/services/VehicleService.ts"
    click API "https://github.com/amueed/vehicle-monitoring/blob/main/backend/src/VehicleMonitoring.Api/Program.cs"
    click Domain "https://github.com/amueed/vehicle-monitoring/tree/main/backend/src/VehicleMonitoring.Core/"
    click DataAccess "https://github.com/amueed/vehicle-monitoring/tree/main/backend/src/VehicleMonitoring.Infrastructure/"
    click Docker "https://github.com/amueed/vehicle-monitoring/blob/main/docker-compose.yaml"

    %% Styling for color coding and shape distinction
    classDef frontend fill:#C4E6FF,stroke:#036,stroke-width:2px;
    classDef backend fill:#FFE6C4,stroke:#C63,stroke-width:2px;
    classDef database fill:#FDE68A,stroke:#B26,stroke-width:2px,stroke-dasharray: 5 5;
    classDef docker fill:#E0BBE4,stroke:#A020F0,stroke-width:2px,stroke-dasharray: 2 2;
```
