# lesykkk/drivehub architecture

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

- Interactive diagram: https://gitdiagram.com/lesykkk/drivehub
- Repository: https://github.com/lesykkk/drivehub

## Overview

##### Project type and scope
- DriveHub is a Django-based full-stack web platform for buying/selling vehicles.
- Your custom instruction is “Database tables only,” so we will focus solely on the relational schema layer.

##### Main components (database tables)
- auth_user (or your custom User model in account/models.py)
- account_favourite (stores users’ favorite adverts)
- advert_advert (the vehicle listing)
- advert_filter (advanced search/filter presets)
- advert_review (ratings & reviews for adverts)
- (Plus standard Django tables: auth_group, auth_permission, django_migrations, etc., as needed.)

##### Relationships and interactions
- One-to-many:
- User → Advert (each user can post many adverts)
- User → Review (each user can write many reviews)
- Advert → Review (each advert has many reviews)
- Many-to-many (through a join table):
- User ↔ Advert via Favourite (users can favorite many adverts; adverts can be favorited by many users)
- One-to-one or one-to-many for Profile/Settings depending on your implementation.

##### Architectural pattern
- Simple relational schema (SQLite3)
- Standard normalized relations: separate tables for entities, join tables for M2M, foreign keys for 1-to-many.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Domain
    subgraph "User Domain"
        direction TB
        account_user["account_user\n**id**\nusername\nemail\nrole\npassword"]:::user
        account_profile["account_profile\n**id**\n_user_id_\nfirst_name\nlast_name\navatar\nbio"]:::user
        account_favourite["account_favourite\n**id**\n_user_id_\n_advert_id_\ntimestamp"]:::join
        account_setting["account_setting\n**id**\n_user_id_\nsettings_data"]:::user
    end

    %% Advert Domain
    subgraph "Advert Domain"
        direction TB
        advert_advert["advert_advert\n**id**\n_user_id_\n_category_id_\ntitle\ndescription\nprice\ncreated_at"]:::advert
        advert_category["advert_category\n**id**\nname\n_parent_category_id_"]:::advert
        advert_filter["advert_filter\n**id**\n_user_id_\ncriteria"]:::advert
        advert_review["advert_review\n**id**\n_user_id_\n_advert_id_\nrating\ncomment\ncreated_at"]:::advert
    end

    %% Relationships
    account_user -->|"1-to-1"| account_profile
    account_user -->|"1-to-1"| account_setting
    account_user -->|"1-to-∞"| advert_advert
    account_user -->|"1-to-∞"| advert_review
    account_user -->|"1-to-∞"| advert_filter
    account_user -->|"1-to-∞"| account_favourite
    advert_advert -->|"1-to-∞"| advert_review
    advert_advert -->|"1-to-∞"| account_favourite
    advert_category -->|"1-to-∞"| advert_advert

    %% Legend
    subgraph Legend
        direction TB
        L1["**PK** = Primary Key"] 
        L2["_FK_ = Foreign Key"] 
        L3["1-to-∞ = One-to-Many"] 
        L4["1-to-1 = One-to-One"] 
    end

    %% Click Events
    click account_user "https://github.com/lesykkk/drivehub/blob/main/DriveHub/DriveHub/settings.py"
    click account_profile "https://github.com/lesykkk/drivehub/blob/main/DriveHub/account/models.py"
    click account_favourite "https://github.com/lesykkk/drivehub/blob/main/DriveHub/account/models.py"
    click account_setting "https://github.com/lesykkk/drivehub/blob/main/DriveHub/account/models.py"
    click advert_advert "https://github.com/lesykkk/drivehub/blob/main/DriveHub/advert/models.py"
    click advert_category "https://github.com/lesykkk/drivehub/blob/main/DriveHub/advert/models.py"
    click advert_filter "https://github.com/lesykkk/drivehub/blob/main/DriveHub/advert/models.py"
    click advert_review "https://github.com/lesykkk/drivehub/blob/main/DriveHub/advert/models.py"

    %% Styles
    classDef user fill:#E3F2FD,stroke:#1E88E5,color:#0D47A1;
    classDef advert fill:#FFE0B2,stroke:#FB8C00,color:#E65100;
    classDef join fill:#E8F5E9,stroke:#43A047,color:#1B5E20;
```
