# mharfe23/restaurant-django-rest-api architecture

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

- Interactive diagram: https://gitdiagram.com/mharfe23/restaurant-django-rest-api
- Repository: https://github.com/mharfe23/restaurant-django-rest-api

## Overview

##### Project Type and Purpose
- This is a backend‐only RESTful web service for a restaurant ordering system, built with Django and Django REST Framework. It exposes JSON endpoints for menu browsing, cart management, order placement, and role‐based user management (customers, managers, delivery crew). Authentication and user registration are handled by Djoser.

##### File Structure
- Top-level “LittleLemon” directory: Django project configuration (settings.py, asgi.py, wsgi.py, urls.py).
- “LittleLemonAPI” app directory:
- models.py – data schema for MenuItem, Category, CartItem, Order, etc.
- serializers.py – DTOs converting models ↔ JSON.
- views.py – DRF viewsets and APIViews implementing business logic.
- permissions.py – custom role‐based access control.
- urls.py – app-specific route definitions (prefixed under /api/).
- migrations/ – database evolution scripts.
- manage.py & db.sqlite3 for local development.

##### Extract Additional Insights from README
- REST endpoints are all under /api/, auth endpoints under /auth/ (provided by Djoser).
- Role-based access control: three Django Group roles.
- Key features: filtering/search/pagination, rate-limiting, CRUD on menu/categories/orders, cart operations, user group management via admin or group endpoints.

##### Elements
– Clear rectangular blocks for each component (Client, API Gateway, Views, Serializers, Models, Database, Admin Panel)
- Blue: External actors (Web/Mobile)
- Green: Application layers (Gateway, Views, Serializers)
- Orange: Data layer (Models, Database)
- Purple: Auth services (Djoser token endpoints)
– Annotation of role-based branches in the Views layer (e.g., Customer vs. Manager vs. Delivery Crew)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "External Clients"
        Web["Web UI"]:::external
        Mobile["Mobile App"]:::external
        CLI["CLI"]:::external
    end

    subgraph "Project Configuration"
        Settings["settings.py"]:::gateway
        ASGI["asgi.py"]:::gateway
        WSGI["wsgi.py"]:::gateway
    end

    subgraph "API Gateway / HTTP Layer"
        URLsProject["LittleLemon/urls.py"]:::gateway
        URLsApp["LittleLemonAPI/urls.py"]:::gateway
    end

    subgraph "Authentication Module (Djoser)"
        AuthLogin["/auth/token/login"]:::auth
        AuthVerify["/auth/token/verify"]:::auth
    end

    subgraph "Business Logic Layer"
        Views["views.py"]:::app
        Perms["permissions.py"]:::app
    end

    subgraph "Serialization Layer"
        Ser["serializers.py"]:::app
    end

    subgraph "Data Persistence Layer"
        Models["models.py"]:::data
        subgraph "Migrations"
            Mig1["0001_initial.py"]:::data
            Mig2["0002_rename_category_menuitem_category_alter_order_date_and_more.py"]:::data
        end
        DB["SQLite/PostgreSQL"]:::data
    end

    Admin["admin.py"]:::app
    Tests["tests.py"]:::test
    Manage["manage.py"]:::misc
    DBfile["db.sqlite3"]:::misc

    Web -->|HTTP JSON| URLsProject
    Mobile -->|HTTP JSON| URLsProject
    CLI -->|HTTP JSON| URLsProject
    Manage -->|run commands| Settings
    Manage -->|interacts| DBfile
    URLsProject -->|routes /api/| URLsApp
    URLsProject -->|routes /auth/| AuthLogin
    URLsProject -->|config| Settings
    AuthLogin -->|issues token| AuthVerify
    URLsApp -->|dispatch| Views
    AuthVerify -->|token middleware| Views
    Views -->|enforce| Perms
    Views -->|serialize data| Ser
    Ser -->|ORM operations| Models
    Models -->|persist| DB
    Admin -->|admin UI CRUD| Models

    click Settings "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemon/settings.py"
    click ASGI "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemon/asgi.py"
    click WSGI "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemon/wsgi.py"
    click URLsProject "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemon/urls.py"
    click URLsApp "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemonAPI/urls.py"
    click Views "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemonAPI/views.py"
    click Perms "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemonAPI/permissions.py"
    click Ser "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemonAPI/serializers.py"
    click Models "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemonAPI/models.py"
    click Mig1 "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemonAPI/migrations/0001_initial.py"
    click Mig2 "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemonAPI/migrations/0002_rename_category_menuitem_category_alter_order_date_and_more.py"
    click Admin "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemonAPI/admin.py"
    click Tests "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/LittleLemonAPI/tests.py"
    click Manage "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/manage.py"
    click DBfile "https://github.com/mharfe23/restaurant-django-rest-api/blob/main/db.sqlite3"

    classDef external fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef gateway fill:#90EE90,stroke:#333,stroke-width:1px
    classDef app fill:#32CD32,stroke:#333,stroke-width:1px
    classDef data fill:#FFA500,stroke:#333,stroke-width:1px
    classDef auth fill:#9370DB,stroke:#333,stroke-width:1px
    classDef test fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef misc fill:#CCCCCC,stroke:#333,stroke-width:1px
```
