# majdeddine-oumanni/delivery-match architecture

> Architecture diagram of the GitHub repository majdeddine-oumanni/delivery-match, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/majdeddine-oumanni/delivery-match
- Repository: https://github.com/majdeddine-oumanni/delivery-match

## Overview

##### Project type and purpose
- DeliveryMatch is a full-stack, web-based platform connecting Drivers and Senders to share vehicle space.
- Frontend: Angular 19 single-page application.
- Backend: Spring Boot REST API, Spring Data JPA, Spring Security, MySQL datastore.
- Docker is used for containerization; Postman for API docs; Chart.js on the frontend for statistics.

##### Top-level structure analysis
- /backend: Spring Boot monolith
- src/main/java/com/delivery/backend – controllers, services, models, repos, DTOs, mappers, security config
- application.properties for JDBC / security settings
- Dockerfile, Maven wrapper, pom.xml
- /frontend: Angular project
- src/app: pages (login/register), components (home, users, trips, requests)
- guards, interceptors, services (auth, trip, request)
- Angular Material, Bootstrap, Chart.js integration via components

##### Key insights from README
- Four user roles: User, Driver, Sender, Admin
- Core flows: authentication (JWT), trip posting/searching, package requests, admin moderation, statistics
- Technical stack confirms RESTful API with JWT filter and role-based access

##### Main components and interactions
a. Components
1. Browser / Angular Client
2. Auth Layer (JWT filter + Spring Security)
3. REST Controllers (AuthenticationController, UserController, TripController, PackageRequestController)
4. Service Layer (UserService, TripService, PackageRequestService, AuthenticationService)
5. Data Layer (Spring Data Repositories + JPA Entities against MySQL)
6. MySQL Database
7. External Libraries/Services (Chart.js on frontend, Docker container registry, optional email or map services if used)
b. Relationships & Data‐flow
- User interacts with Angular UI → HTTP(S) calls to backend endpoints via HttpClient
- Interceptor logs requests; guard protects routes → attaches JWT
- Spring Security’s JwtAuthenticationFilter extracts/validates token → forwards to controllers
- Controller invokes Service business logic → Service calls Repository to query/update MySQL
- Responses (DTOs) propagate back to Angular → components render results or update UI
c. Architectural patterns
- Layered architecture: Presentation (Angular) → API Layer → Service Layer → Repository Layer → Database
- DTOs & Mappers isolate entity model from API contracts
- JWT‐based stateless authentication, role‐based access control
- Docker containers to package frontend and backend independently
d. Technologies
- Angular 19, Angular Material, Bootstrap, Chart.js
- Spring Boot, Spring Data JPA, Spring Security, JUnit
- MySQL, Docker

##### Additional notes
- For each user role, annotate which API endpoints they call.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Docker container encompassing server and database
    subgraph "Docker Container" 
        class docker container
        %% Spring Boot Application Container
        subgraph "Spring Boot Service"
            direction TB
            %% Entry Point
            BackendApp["BackendApplication"]:::backendControllers
        end

        %% Security Layer
        subgraph "Security Layer"
            direction TB
            JwtFilter["JwtAuthenticationFilter"]:::security
            JwtService["JwtService"]:::security
            SecurityConfig["SecurityConfiguration"]:::security
        end

        %% Controller Layer
        subgraph "Controller Layer"
            direction TB
            AuthController["AuthenticationController"]:::backendControllers
            UserController["UserController"]:::backendControllers
            TripController["TripController"]:::backendControllers
            PackageRequestController["PackageRequestController"]:::backendControllers
        end

        %% Service Layer
        subgraph "Service Layer"
            direction TB
            AuthService["AuthenticationService"]:::backendServices
            UserService["UserService"]:::backendServices
            TripService["TripService"]:::backendServices
            PackageRequestService["PackageRequestService"]:::backendServices
        end

        %% Repository & Data Layer
        subgraph "Repository & Data Layer"
            direction TB
            Entities["JPA Entities"]:::backendRepos
            Repos["Spring Data Repositories"]:::backendRepos
            DTOsMappers["DTOs & Mappers"]:::backendRepos
        end

        %% MySQL Database
        MySQL["MySQL Database"]:::database
    end

    %% Web Client Container
    subgraph "Web Client (Angular SPA)"
        direction TB
        Browser["Browser / Angular Client"]:::frontend

        subgraph "Pages"
            direction TB
            LoginPage["Login Page"]:::frontend
            RegisterPage["Register Page"]:::frontend
        end

        subgraph "Components"
            direction TB
            HomeComp["Home Component"]:::frontend
            UsersComp["Users Component"]:::frontend
            TripsComp["Trips Component"]:::frontend
            RequestsComp["Requests Component"]:::frontend
        end

        subgraph "Guards & Interceptors"
            direction TB
            AuthGuard["Auth Guard"]:::frontend
            LoggerInterceptor["HTTP Interceptor"]:::frontend
        end

        subgraph "Services"
            direction TB
            FrontAuthService["Auth Service"]:::frontend
            FrontTripService["Trip Service"]:::frontend
            FrontRequestService["Request Service"]:::frontend
        end
    end

    %% Client to Server interactions
    Browser -->|uses| LoginPage
    Browser -->|uses| RegisterPage
    Browser -->|renders| HomeComp
    Browser -->|renders| UsersComp
    Browser -->|renders| TripsComp
    Browser -->|renders| RequestsComp

    HomeComp -->|calls| FrontAuthService
    UsersComp -->|calls| FrontAuthService
    TripsComp -->|calls| FrontTripService
    RequestsComp -->|calls| FrontRequestService

    AuthGuard -->|protects routes| Browser
    LoggerInterceptor -->|logs HTTP calls| Browser

    FrontAuthService -->|HTTP| JwtFilter
    FrontTripService -->|HTTP| JwtFilter
    FrontRequestService -->|HTTP| JwtFilter

    %% Security flow
    JwtFilter -->|validates token| JwtService
    JwtFilter -->|forwards| AuthController

    %% Controller to service
    AuthController -->|invokes| AuthService
    UserController -->|invokes| UserService
    TripController -->|invokes| TripService
    PackageRequestController -->|invokes| PackageRequestService

    %% Service to repository/data
    AuthService -->|queries| Repos
    UserService -->|queries| Repos
    TripService -->|queries| Repos
    PackageRequestService -->|queries| Repos

    Repos -->|operates on| Entities
    DTOsMappers -->|maps| Entities

    %% Repository to DB
    Repos -->|SQL| MySQL

    %% Docker boundary labels
    classDef docker fill:#D7BDE2,stroke:#7D3C98;
    class DockerContainer docker;

    %% Styling
    classDef frontend fill:#AED6F1,stroke:#21618C,color:#154360;
    classDef backendControllers fill:#ABEBC6,stroke:#196F3D,color:#0B5345;
    classDef backendServices fill:#A9DFBF,stroke:#239B56,color:#145A32;
    classDef backendRepos fill:#82E0AA,stroke:#117864,color:#0E6251;
    classDef database fill:#F9E79F,stroke:#B7950B,color:#7D6608;
    classDef security fill:#F5B7B1,stroke:#943126,color:#641E16;

    %% Click Events
    click Browser "https://github.com/majdeddine-oumanni/delivery-match/tree/master/frontend/src/app"
    click LoginPage "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/pages/login/login.component.ts"
    click RegisterPage "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/pages/register/register.component.ts"
    click HomeComp "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/components/home/home.component.ts"
    click UsersComp "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/components/users/users.component.ts"
    click TripsComp "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/components/trips/trips.component.ts"
    click RequestsComp "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/components/requests/requests.component.ts"
    click AuthGuard "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/guards/auth.guard.ts"
    click LoggerInterceptor "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/interceptor/logger.interceptor.ts"
    click FrontAuthService "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/services/auth.service.ts"
    click FrontTripService "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/services/trip.service.ts"
    click FrontRequestService "https://github.com/majdeddine-oumanni/delivery-match/blob/master/frontend/src/app/services/request.service.ts"
    click BackendApp "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/BackendApplication.java"
    click JwtFilter "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/Configuration/JwtAuthenticationFilter.java"
    click JwtService "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/Configuration/JwtService.java"
    click SecurityConfig "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/Configuration/SecurityConfiguration.java"
    click AuthController "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/auth/AuthenticationController.java"
    click UserController "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/Controller/UserController.java"
    click TripController "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/Controller/TripController.java"
    click PackageRequestController "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/Controller/PackageRequestController.java"
    click AuthService "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/auth/AuthenticationService.java"
    click UserService "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/Service/UserService.java"
    click TripService "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/Service/TripService.java"
    click PackageRequestService "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/java/com/delivery/backend/Service/PackageRequestService.java"
    click Entities "https://github.com/majdeddine-oumanni/delivery-match/tree/master/backend/src/main/java/com/delivery/backend/Model"
    click Repos "https://github.com/majdeddine-oumanni/delivery-match/tree/master/backend/src/main/java/com/delivery/backend/Repositories"
    click DTOsMappers "https://github.com/majdeddine-oumanni/delivery-match/tree/master/backend/src/main/java/com/delivery/backend/DTO"
    click DTOsMappers "https://github.com/majdeddine-oumanni/delivery-match/tree/master/backend/src/main/java/com/delivery/backend/Mappers"
    click MySQL "https://github.com/majdeddine-oumanni/delivery-match/blob/master/backend/src/main/resources/application.properties"
```
