# github2k10/safar architecture

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

- Interactive diagram: https://gitdiagram.com/github2k10/safar
- Repository: https://github.com/github2k10/safar

## Overview

##### Project type and purpose
- This is a full-stack web application named “SAFAR – Bus Reservation Management Portal.”
- The FrontEnd directory contains static HTML/CSS/JS files for user and admin UI.
- The Backend directory is a Spring Boot REST API (Java, Spring Data JPA, Hibernate) exposing endpoints for users, admins, buses, routes, reservations, and feedback.
- A MySQL database persists all entities (User, Admin, Bus, Route, Reservation, Feedback, Session).

##### File structure
- Top-level:
- FrontEnd/ → all client-side assets (HTML pages, CSS, JavaScript).
- Backend/bus_reservation/ → Spring Boot project (pom.xml, mvnw, src/main, src/test).
- src/main/java/com/safar:
- controller/ → REST controllers (AdminController, UserController, etc.)
- service/ & serviceImpl/ → business logic layer
- repository/ → Spring Data JPA interfaces for CRUD
- model/ → JPA entities and DTOs
- exception/ → custom exceptions & global handler
- BusReservationApplication.java → main Spring Boot class
- src/main/resources/application.properties → DB configuration
- No separate “infrastructure” folder: DB connection is configured in properties, Swagger UI is auto-exposed by Spring doc dependencies.

##### README for additional insights
- Features: user/admin authentication with session UUIDs, role-based operations, CRUD for buses/routes, reservation workflows, feedback.
- Tech stack: Java, Spring Boot, Hibernate, MySQL, HTML/CSS/JS.

##### Detail without over-segmenting
- Six modules (Login/Logout, Admin, User, Route, Bus, Reservation, Feedback) by listing their controllers/services.
- Session management components (CurrentUserSession, CurrentAdminSession tables).
- External interfaces (payment gateway or email service if added later).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        direction LR
        Browser["Client Browser"]:::ui
        WebServer["Static Web Server"]:::ui
    end

    Browser -->|"requests HTML/CSS/JS"| WebServer
    click WebServer "https://github.com/github2k10/safar/tree/main/FrontEnd/"

    %% Backend Application
    subgraph "Spring Boot REST API"
        direction TB

        %% Controllers Layer
        subgraph "Controllers Layer"
            direction TB
            AdminLoginController["AdminLoginController"]:::controller
            AdminController["AdminController"]:::controller
            UserLoginController["UserLoginController"]:::controller
            UserController["UserController"]:::controller
            BusController["BusController"]:::controller
            RouteController["RouteController"]:::controller
            ReservationController["ReservationController"]:::controller
            FeedbackController["FeedbackController"]:::controller
            SwaggerUI["Swagger UI"]:::doc
        end

        %% Services Layer
        subgraph "Service Layer"
            direction TB
            AdminLoginServiceImpl["AdminLoginServiceImpl"]:::service
            AdminServiceImpl["AdminServiceImpl"]:::service
            UserLoginServiceImpl["UserLoginServiceImpl"]:::service
            UserServiceImpl["UserServiceImpl"]:::service
            BusServiceImpl["BusServiceImpl"]:::service
            RouteServiceImpl["RouteServiceImpl"]:::service
            ReservationServiceImpl["ReservationServiceImpl"]:::service
            FeedbackServiceImpl["FeedbackServiceImpl"]:::service
        end

        %% Repositories Layer
        subgraph "Data Access Layer"
            direction TB
            CurrentAdminSessionRepository["CurrentAdminSessionRepository"]:::repo
            CurrentUserSessionRepository["CurrentUserSessionRepository"]:::repo
            AdminRepository["AdminRepository"]:::repo
            UserRepository["UserRepository"]:::repo
            BusRepository["BusRepository"]:::repo
            RouteRepository["RouteRepository"]:::repo
            ReservationRepository["ReservationRepository"]:::repo
            FeedbackRepository["FeedbackRepository"]:::repo
        end

    end

    %% Database
    MySQLDB["MySQL Database<br/>(User, Admin, Bus, Route, Reservation, Feedback, Session)"]:::database

    %% Flows
    WebServer -->|AJAX/fetch| AdminLoginController
    WebServer -->|AJAX/fetch| UserLoginController
    WebServer -->|AJAX/fetch| AdminController
    WebServer -->|AJAX/fetch| UserController
    WebServer -->|AJAX/fetch| BusController
    WebServer -->|AJAX/fetch| RouteController
    WebServer -->|AJAX/fetch| ReservationController
    WebServer -->|AJAX/fetch| FeedbackController

    %% Controllers to Services
    AdminLoginController -->|calls| AdminLoginServiceImpl
    AdminController -->|calls| AdminServiceImpl
    UserLoginController -->|calls| UserLoginServiceImpl
    UserController -->|calls| UserServiceImpl
    BusController -->|calls| BusServiceImpl
    RouteController -->|calls| RouteServiceImpl
    ReservationController -->|calls| ReservationServiceImpl
    FeedbackController -->|calls| FeedbackServiceImpl

    %% Services to Repositories
    AdminLoginServiceImpl -->|uses| CurrentAdminSessionRepository
    UserLoginServiceImpl -->|uses| CurrentUserSessionRepository
    AdminServiceImpl -->|uses| AdminRepository
    UserServiceImpl -->|uses| UserRepository
    BusServiceImpl -->|uses| BusRepository
    RouteServiceImpl -->|uses| RouteRepository
    ReservationServiceImpl -->|uses| ReservationRepository
    FeedbackServiceImpl -->|uses| FeedbackRepository

    %% Repositories to DB
    CurrentAdminSessionRepository -->|CRUD| MySQLDB
    CurrentUserSessionRepository -->|CRUD| MySQLDB
    AdminRepository -->|CRUD| MySQLDB
    UserRepository -->|CRUD| MySQLDB
    BusRepository -->|CRUD| MySQLDB
    RouteRepository -->|CRUD| MySQLDB
    ReservationRepository -->|CRUD| MySQLDB
    FeedbackRepository -->|CRUD| MySQLDB

    %% Swagger UI
    SwaggerUI -->|docs endpoint| AdminController

    %% Click Events - Controllers
    click AdminLoginController "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/controller/AdminLoginController.java"
    click AdminController "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/controller/AdminController.java"
    click UserLoginController "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/controller/UserLoginController.java"
    click UserController "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/controller/UserController.java"
    click BusController "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/controller/BusController.java"
    click RouteController "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/controller/RouteController.java"
    click ReservationController "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/controller/ReservationController.java"
    click FeedbackController "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/controller/FeedbackController.java"

    %% Click Events - Services
    click AdminLoginServiceImpl "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/service/AdminLoginServiceImpl.java"
    click AdminServiceImpl "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/service/AdminServiceImpl.java"
    click UserLoginServiceImpl "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/service/UserLoginServiceImpl.java"
    click UserServiceImpl "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/service/UserServiceImpl.java"
    click BusServiceImpl "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/service/BusServiceImpl.java"
    click RouteServiceImpl "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/service/RouteServiceImpl.java"
    click ReservationServiceImpl "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/service/ReservationServiceImpl.java"
    click FeedbackServiceImpl "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/service/FeedbackServiceImpl.java"

    %% Click Events - Repositories
    click CurrentAdminSessionRepository "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/repository/CurrentAdminSessionRepository.java"
    click CurrentUserSessionRepository "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/repository/CurrentUserSessionRepository.java"
    click AdminRepository "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/repository/AdminRepository.java"
    click UserRepository "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/repository/UserRepository.java"
    click BusRepository "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/repository/BusRepository.java"
    click RouteRepository "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/repository/RouteRepository.java"
    click ReservationRepository "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/repository/ReservationRepository.java"
    click FeedbackRepository "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/repository/FeedbackRepository.java"

    %% Click Event - Application Main
    click BusReservationApplication "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/java/com/safar/BusReservationApplication.java"

    %% Click Event - Config
    click SwaggerUI "https://github.com/github2k10/safar/blob/main/Backend/bus_reservation/src/main/resources/application.properties"

    %% Styles
    classDef ui fill:#D0E6F9,stroke:#0366d6,color:#0366d6,stroke-width:1px;
    classDef controller fill:#d2f8d2,stroke:#28a745,color:#155724,stroke-width:1px;
    classDef service fill:#e2f0cb,stroke:#6c757d,color:#343a40,stroke-width:1px;
    classDef repo fill:#fff3cd,stroke:#856404,color:#856404,stroke-width:1px;
    classDef database fill:#ffd8a8,stroke:#e36209,color:#662d91,stroke-width:1px;
    classDef doc fill:#f0f0f0,stroke:#6c757d,color:#333,stroke-width:1px;
```
