# dcaybe/web_nckh9 architecture

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

- Interactive diagram: https://gitdiagram.com/dcaybe/web_nckh9
- Repository: https://github.com/dcaybe/web_nckh9

## Overview

##### Project type and purpose
- This is a full-stack Django web application (“web_nckh9” project + “app_nckh9” app) that provides:
– Multi-role interfaces (admin, teacher, student) with HTML/CSS/JS frontends
– RESTful/DRF APIs (“api_views.py”, serializers)
– Background processing (Celery tasks)
– An embedded AI chatbot service (under app_nckh9/kaira_chatbot)
– File uploads/media management and static asset delivery

##### File structure
- Top-level:
– manage.py, web_nckh9/ (settings, wsgi, asgi), app_nckh9/ (Django app)
– staticfiles/ & media/uploads/ (collected assets, user uploads)
– db.sqlite3 (development DB), redis.log, celery.py, tasks.py
- app_nckh9/:
– api_views.py, serializers.py → API layer
– views.py, templates/, static/js & static/css → frontend rendering
– migrations/ → schema migrations (SQLite or Postgres in prod)
– celery.py, tasks.py → Celery worker definitions
– kaira_chatbot/ → embedded chatbot: vector store (FAISS), embedding & LLM caches, model binaries, chat routing (main.py)
- External integrations:
– Redis as Celery broker & cache (redis.log)
– Potential third-party LLM API or local model files

##### README/architecture.md
- No content provided, but conventions like architecture.md indicate intention to document modules & flows
- Rely on file names and folder structure to reconstruct component interactions

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Browser (Admin/Teacher/Student)"]:::frontend
        StaticServer["Staticfiles / CDN"]:::frontend
    end

    %% Business Layer
    subgraph "Business Layer"
        Manage["manage.py"]:::backend
        DjangoApp["Django Web App"]:::backend
        CeleryWorker["Celery Worker"]:::backend
        Chatbot["Chatbot Service"]:::ai
    end

    %% Data Layer
    subgraph "Data Layer"
        Database["Database (SQLite/Postgres)"]:::datastore
        Media["Media Storage"]:::datastore
        Redis["Redis (Broker/Cache)"]:::datastore
        VectorStore["Vector Store & Caches"]:::datastore
        ExtLLM["External LLM API"]:::external
    end

    %% Connections
    Browser -->|HTTP/HTTPS| DjangoApp
    Browser -->|Static Asset Request| StaticServer
    DjangoApp -->|Serve Static| StaticServer
    DjangoApp -->|Enqueue Task| Redis
    DjangoApp -->|Cache Read/Write| Redis
    DjangoApp -->|Read/Write| Database
    DjangoApp -->|Store/Retrieve| Media
    DjangoApp -->|Invoke Chatbot| Chatbot

    CeleryWorker -->|Fetch Task| Redis
    CeleryWorker -->|Store Results| Database
    CeleryWorker -->|Store Files| Media
    Redis -->|Deliver Task| CeleryWorker

    Chatbot -->|Vector Search| VectorStore
    Chatbot -->|LLM Invocation| ExtLLM
    VectorStore -->|Return Vectors| Chatbot
    ExtLLM -->|Generate Response| Chatbot
    Chatbot -->|Return Response| DjangoApp

    %% Click Events
    click Manage "https://github.com/dcaybe/web_nckh9/blob/main/manage.py"
    click DjangoApp "https://github.com/dcaybe/web_nckh9/blob/main/web_nckh9/settings.py"
    click DjangoApp "https://github.com/dcaybe/web_nckh9/blob/main/web_nckh9/urls.py"
    click DjangoApp "https://github.com/dcaybe/web_nckh9/blob/main/web_nckh9/wsgi.py"
    click DjangoApp "https://github.com/dcaybe/web_nckh9/blob/main/web_nckh9/asgi.py"
    click CeleryWorker "https://github.com/dcaybe/web_nckh9/blob/main/celery.py"
    click CeleryWorker "https://github.com/dcaybe/web_nckh9/blob/main/app_nckh9/celery.py"
    click Chatbot "https://github.com/dcaybe/web_nckh9/blob/main/app_nckh9/kaira_chatbot/main.py"
    click VectorStore "https://github.com/dcaybe/web_nckh9/blob/main/app_nckh9/kaira_chatbot/cache/faiss.index"
    click Database "https://github.com/dcaybe/web_nckh9/blob/main/db.sqlite3"
    click Media "https://github.com/dcaybe/web_nckh9/tree/main/media/uploads/"
    click StaticServer "https://github.com/dcaybe/web_nckh9/tree/main/staticfiles/"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0066CC,color:#000
    classDef backend fill:#DFF2D8,stroke:#2E8B57,color:#000
    classDef datastore fill:#FFEFD5,stroke:#FF8C00,color:#000
    classDef ai fill:#E8DAEF,stroke:#8E44AD,color:#000
    classDef external fill:#F2F3F4,stroke:#7F8C8D,color:#000
```
