# kkgiorgos/ntua-ece-softeng architecture

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

- Interactive diagram: https://gitdiagram.com/kkgiorgos/ntua-ece-softeng
- Repository: https://github.com/kkgiorgos/ntua-ece-softeng

## Overview

This project is a full‐stack toll management system called Toll Connect that handles toll interoperability, managing transactions, settlements, and data analysis between different toll operators. The system is divided into several key components:

##### Main Components
- Backend Server – Implements a REST API using Deno. It is responsible for handling toll transactions, processing data, enforcing authentication (via JWT), and performing database operations (inserts, finds, deletes) with clearly separated modules (e.g., api routes, models, and database functions).
- Frontend Web Application – Built with Deno and a modern JavaScript framework (React with TypeScript) using Vite. It manages data visualization and analysis through components (charts, maps, dashboards) and consumes the API provided by the backend.
- CLI Tool – A command-line interface distributed under the cli-client directory that provides administrative utilities, such as resetting passes or viewing reports. This tool interacts with the backend or directly with data files.
- API Documentation – Located in the api folder (with an OpenAPI JSON and a Postman collection) which communicates the structure and usage of the REST endpoints.
- Supporting and Deployment Infrastructure – Dockerfiles for front-end, back-end, and auto-tool-docker, along with a docker-compose configuration (compose.yaml), enable containerization and seamless deployment for different services.
- Data Layers – While not an actual database server is detailed in the tree, there is a db-datadump directory that includes JSON dumps of toll-related data which indicates how data might be structured or initially loaded.

##### Relationships and Interactions
- The Frontend communicates with the Backend API over HTTP (REST endpoints) to retrieve toll data, statistics, and facilitate transactions.
- The Backend, using its well-organized routing and modular design (authentication, API, database functions), processes requests from both the Frontend and the CLI tool.
- The CLI interacts with the backend services or directly with the database functions (via Deno scripts) to allow administrators to manage toll operations and view analytical reports.
- Docker and Docker Compose are used to deploy these services, exposing the backend API on port 9115 and serving the frontend via Apache on port 80, ensuring that all components work together in a containerized environment.
- The API documentation (via OpenAPI and Postman documentation) serves as the contract between the frontend and backend, ensuring consistency in data exchange.

##### Architectural Patterns and Design Principles
- Separation of Concerns – Each component (frontend, backend, CLI) has a clear responsibility with appropriate modularization. The backend clearly separates API routes, business logic (e.g., authentication, data operations), and models.
- RESTful API Design – The backend’s use of routes and controllers suggests a RESTful architecture for communication.
- Containerization – With Docker and Docker Compose files included, the system is designed for containerized deployment, promoting consistency across environments.
- Scalability and Maintainability – The project structure with specific directories for data functions, models, and clearly segregated front-end components indicates an architecture designed for ease of maintenance and potential future expansion.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE("Frontend Web Application<br/>React/TSX (Vite)"):::frontend
    end

    %% Backend Layer with components
    subgraph "Backend Layer"
        BE("Backend Server<br/>Deno REST API"):::backend
        API_Routes("API Routes"):::backend
        Auth("Authentication (JWT)"):::backend
        DB_Func("Database Functions"):::backend
        Models("Data Models"):::backend
    end

    %% CLI Tool
    subgraph "CLI Tool"
        CLI("CLI Tool"):::cli
    end

    %% Data & Documentation
    subgraph "Data & Documentation"
        DB("Data Layer<br/>JSON Dumps"):::database
        DOC("API Documentation<br/>OpenAPI & Postman"):::docs
    end

    %% Deployment Infrastructure
    subgraph "Deployment Infrastructure"
        BE_DOCK("Backend Dockerfile"):::deployment
        FE_DOCK("Frontend Dockerfile"):::deployment
        AT_DOCK("Auto-tool Dockerfile"):::deployment
        COMP("Compose Configuration"):::deployment
    end

    %% Relationships
    FE -->|"REST_calls"| BE
    CLI -->|"Admin_calls"| BE

    BE -->|"Uses_routes"| API_Routes
    BE -->|"Auth_logic"| Auth
    BE -->|"DB_queries"| DB_Func
    BE -->|"Data_models"| Models
    BE -->|"Queries"| DB

    DOC -.->|"API_contract"| BE
    DOC -.->|"API_contract"| FE

    BE_DOCK --- BE
    FE_DOCK --- FE
    AT_DOCK --- CLI
    COMP --- BE
    COMP --- FE
    COMP --- CLI

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef cli fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef database fill:#FDFD96,stroke:#333,stroke-width:2px;
    classDef docs fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef deployment fill:#FFD700,stroke:#333,stroke-width:2px;

    %% Click Events
    click BE "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/back-end/"
    click API_Routes "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/back-end/api"
    click Auth "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/back-end/authentication"
    click DB_Func "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/back-end/data-base_functions"
    click Models "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/back-end/models"
    click FE "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/front-end/"
    click CLI "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/cli-client/"
    click DOC "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/api/"
    click DB "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/db-datadump/"
    click BE_DOCK "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/back-end/Dockerfile"
    click FE_DOCK "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/front-end/Dockerfile"
    click AT_DOCK "https://github.com/kkgiorgos/ntua-ece-softeng/tree/main/ai-log/auto-tool-docker/Dockerfile"
    click COMP "https://github.com/kkgiorgos/ntua-ece-softeng/blob/main/compose.yaml"
```
