# 7hsk/car_rental architecture

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

- Interactive diagram: https://gitdiagram.com/7hsk/car_rental
- Repository: https://github.com/7hsk/car_rental

## Overview

1. **Project type and runtime**
   - This is a **desktop C application** for car-rental management, not a web service.
   - The README says it uses **GTK/GTK4** for the UI, and the build tree shows a single CMake-built executable: `car_rental.exe`.

2. **Top-level application structure**
   - `main.c` is the entry point and likely owns startup, screen switching, and role dispatch.
   - The codebase is split into small feature modules: `login`, `signup`, `admin`, `client`, `user`, `car`, `mod`, `req`, plus shared `utils`.

3. **Role-based architecture**
   - The app has two primary user roles:
     - **Admin**: manage vehicles, brands, and rental requests.
     - **Client**: submit and track rental requests.
   - The role boundary is a major architectural split: after authentication, the app routes users into different UI and business flows.

4. **Authentication and account lifecycle**
   - `login.c/.h` and `signup.c/.h` handle credential entry and account creation.
   - `signup_data.txt` suggests user credentials or registration records are persisted locally rather than in an external database.
   - The README’s fixed admin account indicates a built-in or special-case admin login path.

5. **Domain model boundaries**
   - `user.h`, `car.h`, and `req.h` likely define the core data structures for the system:
     - user/account data
     - car inventory and metadata
     - rental request records
   - `admin.h` and `client.h` likely encapsulate operations available to each role.
   - `mod.c/.h` appears to handle update/modify operations on stored records.

6. **Persistence layer**
   - The application uses a **filesystem-backed storage model**, not a database server.
   - There are three clear storage areas:
     - `DataBase/` with many `.bin` files for general records
     - `DataBase_cars/` for car-related reference data
     - `DataBase_txt/` with many `user-data*.txt` files
   - This suggests custom serialization and manual file I/O are central to the architecture.

7. **Car catalog storage**
   - `DataBase_cars/DataBase_brands/*.bin` stores brand records.
   - `DataBase_cars/DataBase_models/*.bin` stores model records.
   - `brands_list.txt` and `models.txt` look like index or lookup files used to validate or populate UI selections.
   - Brand/model lookup is therefore separated from transactional request data.

8. **Request and inventory flow**
   - A client likely creates a rental request through the UI.
   - That request is persisted into one of the local data files, then reviewed or updated by an admin.
   - Admin actions probably include approval/rejection, status updates, and price or inventory changes.
   - The README explicitly mentions automated request processing and status updates, so request state is a key workflow.

9. **Validation and utility layer**
   - `utils.c/.h` likely contains shared helpers for:
     - file access
     - string manipulation
     - input validation
     - formatting or UI support
   - `utils_png` suggests image assets or image-processing support for the GTK interface.

10. **Build and dependency management**
   - The project is built with **CMake**.
   - The build directory shows a vendored dependency for **cJSON**, so JSON parsing/serialization is probably used in at least part of the workflow.
   - This matters architecturally because some data interchange or config handling may be structured through JSON even though the main persistence is file-based.

11. **Data organization pattern**
   - The large number of `.bin` and `user-data*.txt` files implies a **many-file storage scheme** rather than a single consolidated database.
   - That usually means each entity or record type is stored independently, which affects how diagrammed flows should show read/write access to specific folders.

12. **What to show in an architecture diagram**
   - Draw the system as a **single GTK desktop client** with these internal subsystems:
     - UI/bootstrap
     - authentication
     - admin workflows
     - client workflows
     - shared utilities/validation
     - file-based persistence
   - Show local filesystem storage as the only backend boundary, with separate folders for users, cars, brands/models, and request/customer data.

Main entry points: [`car.c`](https://github.com/7hsk/car_rental/blob/master/car.c) (Car Model), [`main.c`](https://github.com/7hsk/car_rental/blob/master/main.c) (Main), [`login.c`](https://github.com/7hsk/car_rental/blob/master/login.c) (Login), [`admin.c`](https://github.com/7hsk/car_rental/blob/master/admin.c) (Admin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_app["Desktop App"]
  node_n_main["Main<br/>entry/bootstrap<br/>[main.c]"]
  node_n_gui_assets["GTK Assets<br/>ui assets"]
  node_n_cjson["cJSON<br/>json dependency"]
end

subgraph group_g_domain["Domain Logic"]
  node_n_login["Login<br/>auth ui<br/>[login.c]"]
  node_n_signup["Signup<br/>account ui<br/>[signup.c]"]
  node_n_admin["Admin<br/>[admin.c]"]
  node_n_client["Client<br/>[client.c]"]
  node_n_user{{"User Model<br/>account model<br/>[user.c]"}}
  node_n_car{{"Car Model<br/>inventory model<br/>[car.c]"}}
  node_n_req{{"Request<br/>rental record<br/>[req.h]"}}
  node_n_mod["Modify<br/>record update<br/>[mod.c]"]
  node_n_utils["Utils<br/>shared helpers<br/>[utils.c]"]
end

subgraph group_g_storage["Local Storage"]
  node_n_data_users[("User Files<br/>text storage")]
  node_n_data_records[("Record DB<br/>binary storage")]
  node_n_data_brands[("Brands DB<br/>catalog storage")]
  node_n_data_models[("Models DB<br/>catalog storage")]
  node_n_brand_index["Brand Index<br/>lookup list<br/>[brands_list.txt]"]
  node_n_model_index["Model Index<br/>lookup list<br/>[models.txt]"]
end

node_n_main -->|"opens"| node_n_login
node_n_main -->|"registration"| node_n_signup
node_n_login -->|"admin path"| node_n_admin
node_n_login -->|"client path"| node_n_client
node_n_signup -->|"creates"| node_n_user
node_n_login -->|"reads"| node_n_user
node_n_admin -->|"manages"| node_n_car
node_n_admin -->|"reviews"| node_n_req
node_n_client -->|"submits"| node_n_req
node_n_client -->|"browses"| node_n_car
node_n_admin -->|"modifies"| node_n_mod
node_n_client -->|"updates"| node_n_mod
node_n_user -->|"persists"| node_n_data_users
node_n_req -->|"persists"| node_n_data_records
node_n_car -->|"reads"| node_n_data_brands
node_n_car -->|"reads"| node_n_data_models
node_n_car -->|"indexes"| node_n_brand_index
node_n_car -->|"indexes"| node_n_model_index
node_n_utils -->|"helps"| node_n_data_users
node_n_utils -->|"helps"| node_n_data_records
node_n_utils -->|"parses"| node_n_cjson
node_n_main -->|"uses"| node_n_utils
node_n_main -->|"loads"| node_n_gui_assets

click node_n_main "https://github.com/7hsk/car_rental/blob/master/main.c"
click node_n_login "https://github.com/7hsk/car_rental/blob/master/login.c"
click node_n_signup "https://github.com/7hsk/car_rental/blob/master/signup.c"
click node_n_admin "https://github.com/7hsk/car_rental/blob/master/admin.c"
click node_n_client "https://github.com/7hsk/car_rental/blob/master/client.c"
click node_n_user "https://github.com/7hsk/car_rental/blob/master/user.c"
click node_n_car "https://github.com/7hsk/car_rental/blob/master/car.c"
click node_n_req "https://github.com/7hsk/car_rental/blob/master/req.h"
click node_n_mod "https://github.com/7hsk/car_rental/blob/master/mod.c"
click node_n_utils "https://github.com/7hsk/car_rental/blob/master/utils.c"
click node_n_gui_assets "https://github.com/7hsk/car_rental/tree/master/utils_png"
click node_n_data_users "https://github.com/7hsk/car_rental/tree/master/DataBase_txt"
click node_n_data_records "https://github.com/7hsk/car_rental/tree/master/DataBase"
click node_n_data_brands "https://github.com/7hsk/car_rental/tree/master/DataBase_cars/DataBase_brands"
click node_n_data_models "https://github.com/7hsk/car_rental/tree/master/DataBase_cars/DataBase_models"
click node_n_brand_index "https://github.com/7hsk/car_rental/blob/master/DataBase_cars/brands_list.txt"
click node_n_model_index "https://github.com/7hsk/car_rental/blob/master/DataBase_cars/models.txt"
click node_n_cjson "https://github.com/7hsk/car_rental/tree/master/cmake-build-debug/_deps/cjson-subbuild"

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_n_main,node_n_gui_assets,node_n_cjson toneBlue
class node_n_login,node_n_signup,node_n_admin,node_n_client,node_n_user,node_n_car,node_n_req,node_n_mod,node_n_utils toneAmber
class node_n_data_users,node_n_data_records,node_n_data_brands,node_n_data_models,node_n_brand_index,node_n_model_index toneMint
```

## Components

### Desktop App

GTK desktop client, startup, and role-based screen flow.

- [Main](https://github.com/7hsk/car_rental/blob/master/main.c): entry/bootstrap · Application entry point and startup router. · `main.c`
- [GTK Assets](https://github.com/7hsk/car_rental/tree/master/utils_png): ui assets · Image or GTK UI asset support used by the desktop interface. · `utils_png`
- [cJSON](https://github.com/7hsk/car_rental/tree/master/cmake-build-debug/_deps/cjson-subbuild): json dependency · Vendored JSON library used for structured data handling. · `cmake-build-debug/_deps/cjson-subbuild`

### Domain Logic

Authentication, role workflows, and record management.

- [Login](https://github.com/7hsk/car_rental/blob/master/login.c): auth ui · Credential entry and sign-in handling. · `login.c`
- [Signup](https://github.com/7hsk/car_rental/blob/master/signup.c): account ui · Account creation and registration flow. · `signup.c`
- [Admin](https://github.com/7hsk/car_rental/blob/master/admin.c): admin flow · Administrative screens and management actions. · `admin.c`
- [Client](https://github.com/7hsk/car_rental/blob/master/client.c): client flow · Customer-facing request and tracking flow. · `client.c`
- [User Model](https://github.com/7hsk/car_rental/blob/master/user.c): account model · Shared user/account data structures and logic. · `user.c`
- [Car Model](https://github.com/7hsk/car_rental/blob/master/car.c): inventory model · Vehicle data structures and catalog operations. · `car.c`
- [Request](https://github.com/7hsk/car_rental/blob/master/req.h): rental record · Rental request data and status handling. · `req.h`
- [Modify](https://github.com/7hsk/car_rental/blob/master/mod.c): record update · Update and modify operations on stored records. · `mod.c`
- [Utils](https://github.com/7hsk/car_rental/blob/master/utils.c): shared helpers · Common helpers for validation, formatting, and file access. · `utils.c`

### Local Storage

Filesystem-backed persistence and lookup data.

- [User Files](https://github.com/7hsk/car_rental/tree/master/DataBase_txt): text storage · Local text-backed user and registration records. · `DataBase_txt`
- [Record DB](https://github.com/7hsk/car_rental/tree/master/DataBase): binary storage · Binary record storage for application data. · `DataBase`
- [Brands DB](https://github.com/7hsk/car_rental/tree/master/DataBase_cars/DataBase_brands): catalog storage · Brand lookup and reference files. · `DataBase_cars/DataBase_brands`
- [Models DB](https://github.com/7hsk/car_rental/tree/master/DataBase_cars/DataBase_models): catalog storage · Model lookup and reference files. · `DataBase_cars/DataBase_models`
- [Brand Index](https://github.com/7hsk/car_rental/blob/master/DataBase_cars/brands_list.txt): lookup list · Brand list file used for selection or validation. · `DataBase_cars/brands_list.txt`
- [Model Index](https://github.com/7hsk/car_rental/blob/master/DataBase_cars/models.txt): lookup list · Model list file used for selection or validation. · `DataBase_cars/models.txt`

## Connections

- Main → Login: opens · Startup routes into authentication.
- Main → Signup: registration · Launches account creation when needed.
- Login → Admin: admin path · Authenticated admin users enter management workflows.
- Login → Client: client path · Authenticated customers enter request workflows.
- Signup → User Model: creates · Registration produces shared account data.
- Login → User Model: reads · Sign-in validates against stored account records.
- Admin → Car Model: manages · Admin workflows update vehicle inventory.
- Admin → Request: reviews · Admin approves, rejects, or updates rental requests.
- Client → Request: submits · Client workflow creates and tracks requests.
- Client → Car Model: browses · Client views available cars and catalog data.
- Admin → Modify: modifies · Admin changes stored records through update logic.
- Client → Modify: updates · Client-side request changes may pass through shared modify logic.
- User Model → User Files: persists · Account and signup data is stored locally.
- Request → Record DB: persists · Requests and status records are written to binary storage.
- Car Model → Brands DB: reads · Brand metadata is loaded from local catalog storage.
- Car Model → Models DB: reads · Model metadata is loaded from local catalog storage.
- Car Model → Brand Index: indexes · Brand selection uses a lookup file.
- Car Model → Model Index: indexes · Model selection uses a lookup file.
- Utils → User Files: helps · Shared helpers support file and text processing.
- Utils → Record DB: helps · Shared helpers support binary I/O and validation.
- Utils → cJSON: parses · Utilities may serialize or parse structured JSON data.
- Main → Utils: uses · Bootstrap relies on shared helper routines.
- Main → GTK Assets: loads · UI startup references image or GTK asset support.
