# habibul610/driveflow architecture

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

- Interactive diagram: https://gitdiagram.com/habibul610/driveflow
- Repository: https://github.com/habibul610/driveflow

## Overview

1. **Overall shape**
   - This is a **desktop car rental management system** built as a **.NET 10 Windows Forms** application.
   - The repo is organized as a classic **three-tier architecture**: **UI → BLL → DAL → SQL Server**, with shared **Models** and cross-cutting **Helpers**.

2. **Presentation layer**
   - The `UI/` folder contains the WinForms screens for all user workflows: login, registration, customer booking, manager booking approval/returns, car management, user management, billing, coupons, reviews, messaging, GPS simulation, and AI chat.
   - The `UI/Controls/CarCard` component suggests the car browsing experience is built from reusable UI tiles/cards rather than a single monolithic form.

3. **Role-based application flow**
   - The app centers around three personas: **Admin**, **Manager**, and **Customer**.
   - Each role has its own home screen and feature set, so the navigation and available operations are determined by the authenticated user type.
   - `Helpers/SessionManager.cs` is likely the in-memory state holder for the current logged-in user and role.

4. **Business logic layer**
   - `BLL/` contains one service class per major domain: bookings, cars, billing, coupons, feedback, GPS, messages, reviews, and users.
   - This layer appears to enforce rules such as booking eligibility, pricing, discounts, return processing, and role-specific permissions before any database write happens.
   - The BLL is the main boundary between UI events and persistence.

5. **Data access layer**
   - `DAL/` mirrors the BLL structure with one repository-like class per domain plus `DBConnection.cs`.
   - This layer is responsible for direct SQL Server access using ADO.NET-style operations and centralizes the connection string and query execution.
   - The existence of domain-specific DAL classes indicates the data model is split by business capability rather than a single generic repository.

6. **Domain model**
   - `Models/` defines the core entities: `User`, `Admin`, `Manager`, `Customer`, `Car`, `Booking`, `Billing`, `DiscountCoupon`, `Review`, `Feedback`, `Message`, `GPSLog`, `GeoLocation`, and `VehicleType`.
   - `Models/IVehicle.cs` suggests the system treats cars through a common vehicle abstraction, likely to support reusable comparison, pricing, or display logic.
   - These models are the shared contract between UI, business logic, and persistence.

7. **Database boundary**
   - The repository is backed by **Microsoft SQL Server**, with schema and seed data managed in `database.sql` and additional migration scripts in `Database/`.
   - The scripts cover schema setup plus later changes such as payment options, image paths, and password fixes, which suggests the database evolved through multiple project phases.
   - Default sample accounts and records are seeded from the database scripts, not hardcoded in the app.

8. **Booking, pricing, and billing flow**
   - The core runtime flow is: customer selects a car in the UI, BLL validates availability and computes pricing, DAL persists booking rows, and later the manager processes the return.
   - `Helpers/CalculationHelper.cs` likely handles fare math, discounts, and late-fee calculations.
   - `Billing` is treated as a separate concern from `Booking`, which implies the app distinguishes reservation state from invoice/settlement state.

9. **Payments and invoices**
   - The app includes a payment screen and generated invoice artifacts under `REPORT/`, with `Helpers/PDFGenerator.cs` indicating PDF output is part of the system.
   - This means billing is not just stored in the database; it is also rendered into a document for reporting or customer handoff.
   - The presence of payment-option migration scripts suggests payment behavior is configurable at the data layer.

10. **Messaging, feedback, and reviews**
   - The system includes customer-manager communication via `Message` and `frmMessages` / `frmNewMessage`, plus separate `Feedback` and `Review` features.
   - These are adjacent but distinct flows: messages are for direct communication, feedback is operational input, and reviews are customer-facing evaluation data.
   - This makes the app more than a booking tool; it also supports post-rental customer interaction.

11. **AI and smart-assist features**
   - `Helpers/OllamaService.cs` and the `frmAIInsights`, `frmAISuggestions`, and chat forms show the system integrates with a local **Ollama** AI model.
   - The AI is used as a car-finding assistant, likely consuming car inventory data and user prompts to recommend vehicles.
   - This AI path is an external service boundary separate from SQL Server and should be drawn as such in an architecture diagram.

12. **GPS simulation**
   - `frmGPSSimulation` plus `GPSBLL/GPSDAL` and `Models/GPSLog`, `GeoLocation` indicate a location-tracking or route-simulation feature.
   - Since it is framed as a simulation, it likely doesn’t depend on live telemetry hardware, but it still has its own data flow through the same BLL/DAL pattern.

13. **Cross-cutting helpers**
   - `Helpers/ValidationHelper.cs`, `UIHelper.cs`, `AppConstants.cs`, and `SessionManager.cs` are shared utilities used across forms and services.
   - `Helpers/GenericRepository.cs` suggests some generic data-access patterns exist alongside the domain-specific DAL classes.
   - `Helpers/CalculationHelper.cs` and `PDFGenerator.cs` are important because they support pricing and document creation, two business-visible outputs.

14. **What to draw as the main boundaries**
   - The key diagram boundaries are: **WinForms UI**, **business services**, **data access**, **SQL Server database**, and **external Ollama AI service**.
   - A secondary boundary is the **report/document generation** path, which starts in billing-related flows and ends in PDF output.
   - The architecture is strongly layered, stateful on the client side, and database-centric rather than service-oriented or cloud-native.

Main entry points: [`Helpers/SessionManager.cs`](https://github.com/habibul610/driveflow/blob/main/Helpers/SessionManager.cs) (Helpers), [`DAL/CarDAL.cs`](https://github.com/habibul610/driveflow/blob/main/DAL/CarDAL.cs) (Core DAL), [`UI/frmCustomerHome.cs`](https://github.com/habibul610/driveflow/blob/main/UI/frmCustomerHome.cs) (Customer Flow), [`UI/frmManagerHome.cs`](https://github.com/habibul610/driveflow/blob/main/UI/frmManagerHome.cs) (Staff Ops)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_app(("App Shell<br/>winforms entry<br/>[Program.cs]"))
  node_auth_ui["Auth<br/>screen<br/>[frmLogin.cs]"]
  node_customer_ui["Customer Flow<br/>screen<br/>[frmCustomerHome.cs]"]
  node_staff_ui["Staff Ops<br/>screen<br/>[frmManagerHome.cs]"]
  node_billing_ui["Billing<br/>screen"]
  node_message_ui["Messaging<br/>screen<br/>[frmMessages.cs]"]
  node_ai_ui["AI Assist<br/>screen<br/>[frmAIInsights.cs]"]
  node_gps_ui["GPS Sim<br/>screen"]
  node_car_card["Car Card<br/>ui component<br/>[CarCard.cs]"]
end

subgraph group_business["Business Logic"]
  node_booking_bll["Bookings<br/>[BookingBLL.cs]"]
  node_car_bll["Cars<br/>[CarBLL.cs]"]
  node_billing_bll["Billing<br/>[BillingBLL.cs]"]
  node_message_bll["Messages<br/>[MessageBLL.cs]"]
  node_gps_bll["GPS<br/>[GPSBLL.cs]"]
  node_user_bll["Users<br/>[UserBLL.cs]"]
end

subgraph group_data["Data Access"]
  node_booking_dal["Booking DAL<br/>[BookingDAL.cs]"]
  node_core_dal["Core DAL<br/>[CarDAL.cs]"]
  node_gps_dal["GPS DAL<br/>[GPSDAL.cs]"]
end

subgraph group_core["Core Domain"]
  node_models["Models<br/>domain entities<br/>[User.cs]"]
  node_helpers["Helpers<br/>cross-cutting<br/>[SessionManager.cs]"]
end

subgraph group_integrations["Integrations"]
  node_db[("SQL Server<br/>database<br/>[database.sql]")]
  node_ollama{{"Ollama<br/>ai service<br/>[OllamaService.cs]"}}
  node_pdf["PDF Output<br/>report generator<br/>[PDFGenerator.cs]"]
end

node_app -->|"opens"| node_auth_ui
node_app -->|"navigates"| node_customer_ui
node_app -->|"navigates"| node_staff_ui
node_auth_ui -->|"auth"| node_user_bll
node_customer_ui -->|"browses"| node_car_card
node_customer_ui -->|"books"| node_booking_bll
node_customer_ui -->|"pays"| node_billing_ui
node_staff_ui -->|"approves"| node_booking_bll
node_staff_ui -->|"manages"| node_car_bll
node_staff_ui -->|"administers"| node_user_bll
node_billing_ui -->|"charges"| node_billing_bll
node_message_ui -->|"sends"| node_message_bll
node_gps_ui -->|"simulates"| node_gps_bll
node_ai_ui -->|"queries"| node_ollama
node_booking_bll -->|"persists"| node_booking_dal
node_booking_bll -->|"uses"| node_models
node_car_bll -->|"persists"| node_core_dal
node_billing_bll -->|"persists"| node_core_dal
node_billing_bll -->|"exports"| node_pdf
node_message_bll -->|"persists"| node_core_dal
node_gps_bll -->|"persists"| node_gps_dal
node_user_bll -->|"persists"| node_core_dal
node_booking_dal -->|"sql"| node_db
node_core_dal -->|"sql"| node_db
node_gps_dal -->|"sql"| node_db
node_helpers -->|"supports"| node_user_bll
node_helpers -->|"supports"| node_billing_bll
node_helpers -->|"supports"| node_billing_ui
node_helpers -->|"supports"| node_ai_ui
node_models -.->|"shared"| node_helpers

click node_app "https://github.com/habibul610/driveflow/blob/main/Program.cs"
click node_auth_ui "https://github.com/habibul610/driveflow/blob/main/UI/frmLogin.cs"
click node_customer_ui "https://github.com/habibul610/driveflow/blob/main/UI/frmCustomerHome.cs"
click node_staff_ui "https://github.com/habibul610/driveflow/blob/main/UI/frmManagerHome.cs"
click node_billing_ui "https://github.com/habibul610/driveflow/blob/main/UI/frmPaymentGateway.cs"
click node_message_ui "https://github.com/habibul610/driveflow/blob/main/UI/frmMessages.cs"
click node_ai_ui "https://github.com/habibul610/driveflow/blob/main/UI/frmAIInsights.cs"
click node_gps_ui "https://github.com/habibul610/driveflow/blob/main/UI/frmGPSSimulation.cs"
click node_car_card "https://github.com/habibul610/driveflow/blob/main/UI/Controls/CarCard.cs"
click node_booking_bll "https://github.com/habibul610/driveflow/blob/main/BLL/BookingBLL.cs"
click node_car_bll "https://github.com/habibul610/driveflow/blob/main/BLL/CarBLL.cs"
click node_billing_bll "https://github.com/habibul610/driveflow/blob/main/BLL/BillingBLL.cs"
click node_message_bll "https://github.com/habibul610/driveflow/blob/main/BLL/MessageBLL.cs"
click node_gps_bll "https://github.com/habibul610/driveflow/blob/main/BLL/GPSBLL.cs"
click node_user_bll "https://github.com/habibul610/driveflow/blob/main/BLL/UserBLL.cs"
click node_booking_dal "https://github.com/habibul610/driveflow/blob/main/DAL/BookingDAL.cs"
click node_core_dal "https://github.com/habibul610/driveflow/blob/main/DAL/CarDAL.cs"
click node_gps_dal "https://github.com/habibul610/driveflow/blob/main/DAL/GPSDAL.cs"
click node_db "https://github.com/habibul610/driveflow/blob/main/database.sql"
click node_ollama "https://github.com/habibul610/driveflow/blob/main/Helpers/OllamaService.cs"
click node_pdf "https://github.com/habibul610/driveflow/blob/main/Helpers/PDFGenerator.cs"
click node_models "https://github.com/habibul610/driveflow/blob/main/Models/User.cs"
click node_helpers "https://github.com/habibul610/driveflow/blob/main/Helpers/SessionManager.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_auth_ui,node_customer_ui,node_staff_ui,node_billing_ui,node_message_ui,node_ai_ui,node_gps_ui,node_car_card toneBlue
class node_booking_bll,node_car_bll,node_billing_bll,node_message_bll,node_gps_bll,node_user_bll toneAmber
class node_booking_dal,node_core_dal,node_gps_dal toneMint
class node_models,node_helpers toneRose
class node_db,node_ollama,node_pdf toneIndigo
```

## Components

### Presentation

WinForms screens and reusable UI components

- [App Shell](https://github.com/habibul610/driveflow/blob/main/Program.cs): winforms entry · Desktop application startup and composition root · `Program.cs`
- [Auth](https://github.com/habibul610/driveflow/blob/main/UI/frmLogin.cs): screen · Login and registration workflow · `UI/frmLogin.cs`
- [Customer Flow](https://github.com/habibul610/driveflow/blob/main/UI/frmCustomerHome.cs): screen · Browsing, booking, profile, and bookings · `UI/frmCustomerHome.cs`
- [Staff Ops](https://github.com/habibul610/driveflow/blob/main/UI/frmManagerHome.cs): screen · Admin and manager home workflows · `UI/frmManagerHome.cs`
- [Billing](https://github.com/habibul610/driveflow/blob/main/UI/frmPaymentGateway.cs): screen · Payment and invoice handling · `UI/frmPaymentGateway.cs`
- [Messaging](https://github.com/habibul610/driveflow/blob/main/UI/frmMessages.cs): screen · Direct customer-manager messaging · `UI/frmMessages.cs`
- [AI Assist](https://github.com/habibul610/driveflow/blob/main/UI/frmAIInsights.cs): screen · Insights, suggestions, and chat UI · `UI/frmAIInsights.cs`
- [GPS Sim](https://github.com/habibul610/driveflow/blob/main/UI/frmGPSSimulation.cs): screen · Location and route simulation · `UI/frmGPSSimulation.cs`
- [Car Card](https://github.com/habibul610/driveflow/blob/main/UI/Controls/CarCard.cs): ui component · Reusable car browsing tile · `UI/Controls/CarCard.cs`

### Business Logic

Domain services and application rules

- [Bookings](https://github.com/habibul610/driveflow/blob/main/BLL/BookingBLL.cs): service · Reservation rules and state transitions · `BLL/BookingBLL.cs`
- [Cars](https://github.com/habibul610/driveflow/blob/main/BLL/CarBLL.cs): service · Vehicle inventory and availability rules · `BLL/CarBLL.cs`
- [Billing](https://github.com/habibul610/driveflow/blob/main/BLL/BillingBLL.cs): service · Pricing, settlement, and invoice logic · `BLL/BillingBLL.cs`
- [Messages](https://github.com/habibul610/driveflow/blob/main/BLL/MessageBLL.cs): service · Message and conversation rules · `BLL/MessageBLL.cs`
- [GPS](https://github.com/habibul610/driveflow/blob/main/BLL/GPSBLL.cs): service · GPS simulation and log handling · `BLL/GPSBLL.cs`
- [Users](https://github.com/habibul610/driveflow/blob/main/BLL/UserBLL.cs): service · Authentication, registration, and role access · `BLL/UserBLL.cs`

### Data Access

SQL-facing repositories and connection handling

- [Booking DAL](https://github.com/habibul610/driveflow/blob/main/DAL/BookingDAL.cs): repository · Booking persistence operations · `DAL/BookingDAL.cs`
- [Core DAL](https://github.com/habibul610/driveflow/blob/main/DAL/CarDAL.cs): repository · Car, user, billing, coupon, feedback, review, and message persistence · `DAL/CarDAL.cs`
- [GPS DAL](https://github.com/habibul610/driveflow/blob/main/DAL/GPSDAL.cs): repository · GPS log persistence operations · `DAL/GPSDAL.cs`

### Core Domain

Shared models and cross-cutting helpers

- [Models](https://github.com/habibul610/driveflow/blob/main/Models/User.cs): domain entities · Shared entities and vehicle abstractions · `Models/User.cs`
- [Helpers](https://github.com/habibul610/driveflow/blob/main/Helpers/SessionManager.cs): cross-cutting · Session, validation, calculation, and UI helpers · `Helpers/SessionManager.cs`

### Integrations

External AI, database, and generated reports

- [SQL Server](https://github.com/habibul610/driveflow/blob/main/database.sql): database · Relational storage and seed scripts · `database.sql`
- [Ollama](https://github.com/habibul610/driveflow/blob/main/Helpers/OllamaService.cs): ai service · Local model used for suggestions and chat · `Helpers/OllamaService.cs`
- [PDF Output](https://github.com/habibul610/driveflow/blob/main/Helpers/PDFGenerator.cs): report generator · Invoice and report generation · `Helpers/PDFGenerator.cs`

## Connections

- App Shell → Auth: opens · Launches the authentication entry point
- App Shell → Customer Flow: navigates · Routes authenticated customers to their workspace
- App Shell → Staff Ops: navigates · Routes admins and managers to their dashboards
- Auth → Users: auth · Login and registration calls into user rules
- Customer Flow → Car Card: browses · Uses reusable car tiles for inventory display
- Customer Flow → Bookings: books · Creates and manages customer reservations
- Customer Flow → Billing: pays · Moves from booking into payment flow
- Staff Ops → Bookings: approves · Managers process bookings and returns
- Staff Ops → Cars: manages · Staff manage cars and inventory state
- Staff Ops → Users: administers · Admin workflows manage users and roles
- Billing → Billing: charges · Payment and invoice actions run through billing logic
- Messaging → Messages: sends · Messaging UI invokes message rules
- GPS Sim → GPS: simulates · GPS simulation drives location workflow
- AI Assist → Ollama: queries · AI screens call the local model service
- Bookings → Booking DAL: persists · Reservation rules write through booking repositories
- Bookings → Models: uses · Booking service works with shared entities
- Cars → Core DAL: persists · Inventory logic uses the core repository set
- Billing → Core DAL: persists · Billing and coupon data flow through core repositories
- Billing → PDF Output: exports · Invoices are rendered to PDF output
- Messages → Core DAL: persists · Messages are stored through the core data layer
- GPS → GPS DAL: persists · GPS logs are written through the GPS repository
- Users → Core DAL: persists · Users and roles are stored via data access
- Booking DAL → SQL Server: sql · Booking repository reads and writes SQL Server
- Core DAL → SQL Server: sql · Core repositories execute direct database access
- GPS DAL → SQL Server: sql · GPS data is persisted in the database
- Helpers → Users: supports · Session and validation helpers support application services
- Helpers → Billing: supports · Calculation helper supports pricing logic
- Helpers → Billing: supports · UI helper and session state support payment screens
- Helpers → AI Assist: supports · Shared helpers support AI workflows and state
- Models → Helpers: shared · Shared contracts and utility logic are reused across layers
