# abdullahbakir97/barber-salon architecture

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

- Interactive diagram: https://gitdiagram.com/abdullahbakir97/barber-salon
- Repository: https://github.com/abdullahbakir97/barber-salon

## Overview

##### Project type and purpose
- This is a monolithic full-stack Django web application (“Salon Management System”) enhanced with AJAX & HTMX for dynamic client interactions and a RESTful API (Django REST Framework + drf-yasg).
- It manages salon entities: barbers, appointments, reviews, gallery items, products, service categories, pricing, owner profiles, and user accounts.

##### File structure
- Top-level Django apps:
- accounts/ – user, owner, profile management
- contact/ – core salon entities (barber, appointment, review, gallery, product, message, services) + API serializers/views
- settings/ – salon-wide settings (context processors, owner details, home/404/500 pages)
- project/ – Django project configuration (settings.py, urls.py, wsgi.py, asgi.py)
- Static assets under static/ (CSS, JS, fonts, images) plus collected staticfiles/ for production.
- Media assets under media/ (uploaded images for barbers, gallery, profiles, products, reviews).
- Configuration: requirements.txt, runtime.txt, Procfile (Heroku), dummy_data.py, db.sqlite3 (dev).
- REST documentation static under staticfiles/drf-yasg.

##### README for additional insights
- Core features: CRUD over barbers, appointments, reviews, gallery, products, services, owner management.
- Uses AJAX & HTMX on the client to fetch partial HTML or JSON responses for dynamic updates without full page reloads.
- REST API for external integration.

##### Main components and relationships
a. Client Layer
- Web Browser / Mobile Client
- Renders HTML (Django templates + static assets)
- Sends HTTP requests (full page load, AJAX calls, HTMX requests, REST API calls).
b. Web & Application Layer
- Web server (e.g., Gunicorn behind Nginx/Heroku router)
- Django application (project/ + apps) implementing:
- URL routing (project/urls.py → app urls)
- Views:
– Template views (accounts.views, contact.views, settings.views)
– API endpoints (contact/api.py, DRF viewsets/serializers)
- Business logic in forms.py, models.py, context processors, custom pagination/filter classes.
c. Data Layer
- Relational database (PostgreSQL/MySQL in production; SQLite in development)
- Django ORM mapping (models in accounts/models.py, contact/models.py, settings/models.py).
d. Static & Media Storage
- Static files served via WhiteNoise or CDN (collected under staticfiles/)
- Uploaded media (local media/ folder or AWS S3 in production).
e. External Services (optional)
- SMTP/email service for appointment notifications
- CDN for static content
- Third-party analytics / monitoring.
f. Admin Interface
- Django admin with custom SimpleUI theme (staticfiles/admin/…)
g. API Documentation
- drf-yasg-generated Swagger/Redoc UI under /swagger/ endpoints served by staticfiles/drf-yasg.

##### Architectural patterns & design principles
- Django’s MTV pattern (Model–Template–View)
- Layered architecture: presentation, business logic, data access
- App modularity: each Django app encapsulates a domain concept
- AJAX & HTMX progressive enhancement: partial page updates
- RESTful API design for external integrations
- Separation of static, media, and dynamic content.

##### Detail & separation
- Both template rendering paths and API paths.
- API docs endpoint as a separate node.
- Content flow for appointment scheduling (client → AJAX → Appointment API → DB → response).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Client["Web/Mobile Client"]:::frontend
    Client -->|"HTTP GET/POST"| WebServer
    Client -->|"AJAX/HTMX/REST"| WebServer
    Client -->|"Access API Docs"| APIDocs
    Client -->|"Fetch Static Assets"| StaticProd

    %% Web Server
    WebServer["Nginx/Heroku Router\nGunicorn"]:::backend
    WebServer -->|"WSGI calls"| AccountsApp
    WebServer -->|"WSGI calls"| ContactApp
    WebServer -->|"WSGI calls"| SettingsApp
    WebServer -->|"WSGI calls"| ProjectConfig
    WebServer -->|"WSGI calls"| AdminInterface

    %% Django Application Layer
    subgraph "Accounts App"
        direction TB
        AccountsApp["Accounts App"]:::backend
        AA_models["Models"]:::backend
        AA_views["Views"]:::backend
        AA_forms["Forms"]:::backend
        AA_urls["URLs"]:::backend
        AA_templates["Templates"]:::backend
        AA_admin["Admin"]:::backend
    end

    subgraph "Contact App"
        direction TB
        ContactApp["Contact App"]:::backend
        C_models["Models"]:::backend
        C_views["Template Views"]:::backend
        C_forms["Forms"]:::backend
        C_api["API Endpoints"]:::backend
        C_serializers["Serializers"]:::backend
        C_urls["URLs"]:::backend
        C_pagination["Custom Pagination"]:::backend
        C_filter["Custom Filter"]:::backend
        C_context["Context Processor"]:::backend
        C_templates["Templates"]:::backend
    end

    subgraph "Settings App"
        direction TB
        SettingsApp["Settings App"]:::backend
        S_models["Models"]:::backend
        S_views["Views"]:::backend
        S_context["Context Processor"]:::backend
        S_admin["Admin"]:::backend
        S_templates["Templates"]:::backend
    end

    subgraph "Project Configuration"
        direction TB
        ProjectConfig["Project Config"]:::backend
        PC_urls["URL Routing"]:::backend
        PC_settings["Settings"]:::backend
        PC_wsgi["WSGI Entrypoint"]:::backend
        PC_asgi["ASGI Entrypoint"]:::backend
    end

    %% Admin and API Docs
    AdminInterface["Django Admin\n(SimpleUI)"]:::backend
    APIDocs["Swagger/Redoc UI"]:::backend

    %% Data & Storage Layer
    subgraph "Data & Storage"
        direction TB
        DB["Relational DB\n(PostgreSQL/MySQL)"]:::data
        StaticDev["Static (static/)"]:::data
        StaticProd["Collected Static (staticfiles/)"]:::data
        Media["Uploaded Media (media/)"]:::data
    end

    %% External Services
    SMTP["SMTP/Email Service"]:::external
    CDN["CDN for Static Content"]:::external
    Analytics["Analytics/Monitoring"]:::external

    %% Relationships
    AccountsApp -->|"ORM queries"| DB
    ContactApp -->|"ORM queries"| DB
    SettingsApp -->|"ORM queries"| DB
    AdminInterface -->|"ORM queries"| DB

    AccountsApp -->|"serve static"| StaticProd
    ContactApp -->|"serve static"| StaticProd
    SettingsApp -->|"serve static"| StaticProd

    ContactApp -->|"read/write media"| Media
    AccountsApp -->|"read/write media"| Media
    SettingsApp -->|"read/write media"| Media

    ContactApp -->|"send notification"| SMTP
    ContactApp -->|"upload static"| CDN
    ContactApp -->|"collect metrics"| Analytics

    %% Click Events - Accounts App
    click AccountsApp "https://github.com/abdullahbakir97/barber-salon/tree/main/accounts/"
    click AA_models "https://github.com/abdullahbakir97/barber-salon/blob/main/accounts/models.py"
    click AA_views "https://github.com/abdullahbakir97/barber-salon/blob/main/accounts/views.py"
    click AA_forms "https://github.com/abdullahbakir97/barber-salon/blob/main/accounts/forms.py"
    click AA_urls "https://github.com/abdullahbakir97/barber-salon/blob/main/accounts/urls.py"
    click AA_templates "https://github.com/abdullahbakir97/barber-salon/tree/main/accounts/templates/"
    click AA_admin "https://github.com/abdullahbakir97/barber-salon/blob/main/accounts/admin.py"

    %% Click Events - Contact App
    click ContactApp "https://github.com/abdullahbakir97/barber-salon/tree/main/contact/"
    click C_models "https://github.com/abdullahbakir97/barber-salon/blob/main/contact/models.py"
    click C_views "https://github.com/abdullahbakir97/barber-salon/blob/main/contact/views.py"
    click C_forms "https://github.com/abdullahbakir97/barber-salon/blob/main/contact/forms.py"
    click C_api "https://github.com/abdullahbakir97/barber-salon/blob/main/contact/api.py"
    click C_serializers "https://github.com/abdullahbakir97/barber-salon/blob/main/contact/serializers.py"
    click C_urls "https://github.com/abdullahbakir97/barber-salon/blob/main/contact/urls.py"
    click C_pagination "https://github.com/abdullahbakir97/barber-salon/blob/main/contact/mypagination.py"
    click C_filter "https://github.com/abdullahbakir97/barber-salon/blob/main/contact/myfilter.py"
    click C_context "https://github.com/abdullahbakir97/barber-salon/blob/main/contact/review_context_processor.py"
    click C_templates "https://github.com/abdullahbakir97/barber-salon/tree/main/contact/templates/"

    %% Click Events - Settings App
    click SettingsApp "https://github.com/abdullahbakir97/barber-salon/tree/main/settings/"
    click S_models "https://github.com/abdullahbakir97/barber-salon/blob/main/settings/models.py"
    click S_views "https://github.com/abdullahbakir97/barber-salon/blob/main/settings/views.py"
    click S_context "https://github.com/abdullahbakir97/barber-salon/blob/main/settings/salon_context_processor.py"
    click S_admin "https://github.com/abdullahbakir97/barber-salon/blob/main/settings/admin.py"
    click S_templates "https://github.com/abdullahbakir97/barber-salon/tree/main/settings/templates/"

    %% Click Events - Project Config
    click ProjectConfig "https://github.com/abdullahbakir97/barber-salon/tree/main/project/"
    click PC_urls "https://github.com/abdullahbakir97/barber-salon/blob/main/project/urls.py"
    click PC_settings "https://github.com/abdullahbakir97/barber-salon/blob/main/project/settings.py"
    click PC_wsgi "https://github.com/abdullahbakir97/barber-salon/blob/main/project/wsgi.py"
    click PC_asgi "https://github.com/abdullahbakir97/barber-salon/blob/main/project/asgi.py"

    %% Click Events - Static & Media
    click StaticDev "https://github.com/abdullahbakir97/barber-salon/tree/main/static/"
    click StaticProd "https://github.com/abdullahbakir97/barber-salon/tree/main/staticfiles/"
    click Media "https://github.com/abdullahbakir97/barber-salon/tree/main/media/"

    %% Click Events - DB & Dummy Data
    click DB "https://github.com/abdullahbakir97/barber-salon/blob/main/db.sqlite3"
    click dummy_data "https://github.com/abdullahbakir97/barber-salon/blob/main/dummy_data.py"

    %% Styles
    classDef frontend fill:#cfe2f3,stroke:#2e75b6,color:#000;
    classDef backend fill:#d9ead3,stroke:#6aa84f,color:#000;
    classDef data fill:#ffe599,stroke:#bf9000,color:#000;
    classDef external fill:#ead1dc,stroke:#a64d79,color:#000;
```
