# samanba81/note_django architecture

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

- Interactive diagram: https://gitdiagram.com/samanba81/note_django
- Repository: https://github.com/samanba81/note_django

## Overview

##### Project type and purpose
- This is a monolithic, full‐stack web server built with Django. It serves two kinds of front ends:
- A REST API (“apis” app) consumed by an external Flutter mobile client (note_flutter).
- A traditional server‐rendered web UI (“view” app) for end users, plus the built‐in Django admin.
- Purpose: allow users to create, read, update, and delete notes via either the mobile client or a browser interface, and give administrators control over users/notes.

##### File structure
- Top‐level Django project called “Notes” (contains settings, URLs, WSGI/ASGI).
- Two Django apps:
- apis/ – models.py, serializers.py, views.py, URLs, migrations, tests. Exposes REST endpoints.
- view/ – models.py, views.py, URLs, templates/, static/ (CSS/JS), tests. Renders HTML for user login, registration, note listing/editing.
- Configuration: manage.py, db.sqlite3. No Docker or CI files yet.

##### Key insights from README
- Version 1.0 server for note_flutter.
- Provides both API and web view (HTML/CSS/JS).
- Admin interface via Django admin.
- Uses cookies/sessions for the web UI.

##### Main components and their interactions
a. Clients
- Flutter mobile app: issues HTTP(S) requests to /api/... endpoints.
- Web browser: issues HTTP(S) requests to / (login/register), /notes, etc., receives HTML/CSS/JS, uses cookies for session state.
- Admin user: uses Django admin at /admin.
b. Server (Django monolith)
- URL router in Notes/urls.py directs “/api/” to apis/urls.py and other paths to view/urls.py or admin.
- apis app: handles JSON requests, uses DRF serializers, updates models in db.sqlite3.
- view app: renders templates (master.html, notes.html, login/register), serves static assets (forms.css, forms.js), and handles form submissions.
c. Database
- SQLite (db.sqlite3) stores User, Note, NoteColor, and any other models.
d. Optional external services
- (Future) password‐reset email service or cloud DB, but none configured now.

##### Architectural patterns and design principles
- Django’s MVT (Model‐View‐Template) pattern: models in each app, views (controllers) handling request logic, and templates for HTML.
- Separation of concerns:
- REST API layer (apis app) for programmatic clients.
- Server‐rendered UI layer (view app) for browser users.
- Single database for both layers.
- Session management for web UI via cookies.
- Admin interface auto‐generated by Django admin for management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients" 
        direction TB
        Flutter["Flutter Mobile App"]:::external
        Browser["Web Browser"]:::external
        AdminUser["Admin User"]:::external
    end

    %% Server Layer
    subgraph "Django Server (Django 4.x)" 
        direction TB
        Router["URL Router"]:::server
        subgraph "REST API (apis app)\nDRF" 
            direction TB
            ApisApp["apis app"]:::api
        end
        subgraph "Web UI (view app)\nHTML/CSS/JS" 
            direction TB
            ViewApp["view app"]:::ui
        end
        AdminApp["Django Admin"]:::server
    end

    %% Database Layer
    DB["SQLite Database\n(db.sqlite3)"]:::db

    %% Connections
    Flutter -->|"HTTP JSON"| Router
    Browser -->|"HTTP Form & HTML\n(Cookies)"| Router
    AdminUser -->|"CRUD via /admin"| AdminApp

    Router -->|"route /api/…"| ApisApp
    Router -->|"route /…"| ViewApp
    Router -->|"route /admin"| AdminApp

    ApisApp -->|"SQL Read/Write"| DB
    ViewApp -->|"SQL Read/Write"| DB
    AdminApp -->|"SQL Read/Write"| DB

    %% Click Events
    click Router "https://github.com/samanba81/note_django/blob/master/Notes/urls.py"
    click ApisApp "https://github.com/samanba81/note_django/blob/master/apis/apps.py"
    click ViewApp "https://github.com/samanba81/note_django/blob/master/view/apps.py"
    click DB "https://github.com/samanba81/note_django/blob/master/db.sqlite3"

    %% Styles
    classDef external fill:#cce5ff,stroke:#3399ff,color:#003366;
    classDef server fill:#e6ffe6,stroke:#33cc33,color:#006600;
    classDef api fill:#e6ffe6,stroke:#2d862d,color:#004d00;
    classDef ui fill:#e6ffe6,stroke:#2d862d,color:#004d00;
    classDef db fill:#fff0cc,stroke:#ff9933,color:#663300;
```
