# rwr9857/skn14-final-1team-web architecture

> Architecture diagram of the GitHub repository rwr9857/skn14-final-1team-web, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rwr9857/skn14-final-1team-web
- Repository: https://github.com/rwr9857/skn14-final-1team-web

## Overview

#### Purpose and Entry Points
CodeNova is a Django-based internal developer-support system with two AI surfaces: a Google API documentation RAG assistant and a permission-filtered internal-document sLLM chatbot. It also provides account approval, chat persistence, saved cards/API keys, and a community.
- Process/runtime entry points: `manage.py`, `codenova/wsgi.py`, `codenova/asgi.py`
- URL composition and application settings: `codenova/urls.py`, `codenova/settings.py`, `codenova/settings_prod.py`

#### Web Application and Domain Boundaries
The Django project separates user identity, primary product UI/data, API-chat orchestration, internal-chat integration, and personal-content views into apps.
- Primary browser-facing views/templates and chat/community persistence: `main/views.py`, `main/models.py`, `main/urls.py`
- API RAG endpoints and model-facing operations: `apichat/views.py`, `apichat/urls.py`
- Internal chatbot endpoints and remote sLLM client: `internal/views.py`, `internal/utils/sllm.py`
- Signup/login/approval and user organization attributes: `uauth/models.py`, `uauth/views.py`, `uauth/urls.py`

#### API Assistant: LangGraph RAG Pipeline
The API assistant accepts text, image, and voice input; maintains chat context; classifies requests as API/general/unsupported; and uses GPT-4o to answer API questions grounded in retrieval results.
- Workflow assembly and graph nodes: `apichat/utils/main3.py`, `apichat/utils/langgraph_setting2.py`, `apichat/utils/langgraph_node2.py`
- Retrieval combines Chroma/BGE-M3 semantic search and BM25 keyword search, spanning original API documents and generated QA content: `apichat/utils/retriever_hybrid.py`, `apichat/utils/retriever.py`, `apichat/utils/retriever_bm25.py`
- Vector-store boundaries are encapsulated separately for original and QA sources: `apichat/utils/vector_db.py`, `apichat/utils/vector_db_qa.py`
- The graph can evaluate answer quality and retry with regenerated searches; external model calls are to OpenAI GPT-4-class APIs.

#### Multimodal and Object Storage Flow
Uploaded chat images are stored externally and associated with persisted messages; audio is transcribed before entering the same RAG/chat path.
- S3 integration for API-chat uploads: `apichat/aws_s3_service.py`
- Speech-to-text adapter: `apichat/utils/whisper.py`
- Chat/session/message/image and saved-card records: `main/models.py`
- Profile-image S3 handling: `uauth/aws_s3_service.py`

#### Internal sLLM Chat and Authorization Boundary
Internal chat is deliberately separate from the OpenAI API-assistant pipeline. Django obtains the authenticated user’s department/role, limits accessible internal-document retrieval accordingly, and calls a remote fine-tuned Qwen3-8B service. The model decides between direct conversation and document-search tool calls, with formal/informal response modes.
- Django integration boundary: `internal/views.py`, `internal/urls.py`
- Remote sLLM invocation client: `internal/utils/sllm.py`
- User department, rank, and approval state: `uauth/models.py`
- Internal-chat UI is integrated with the main application: `main/templates/my_app/internal_docs.html`, `main/static/my_app/js/chat/chat-internal.js`

#### Persistent Product Data
MySQL is the system of record for users, approval lifecycle, chat sessions/messages/images, saved cards, API keys, posts, comments, and likes. Chroma is a separate retrieval datastore rather than transactional application storage.
- Core product schema: `main/models.py`
- User/approval schema: `uauth/models.py`
- Internal app model boundary: `internal/models.py`

#### Deployment and External Infrastructure
The application is containerized and configured for production Django serving through Gunicorn/Uvicorn. Deployment targets AWS Elastic Beanstalk; MySQL runs separately on EC2. AWS S3 stores user/chat media. The fine-tuned Qwen service is hosted externally on RunPod via vLLM/FastAPI, while API chat uses OpenAI. CI builds container images on GitHub Actions.
- Container and EB descriptors: `Dockerfile`, `Dockerrun.aws.json`
- Gunicorn configuration: `gunicorn.conf.py`
- CI workflow: `.github/workflows/docker-image.yml`

Main entry points: [`codenova/urls.py`](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/codenova/urls.py) (Project routing & settings), [`apichat/views.py`](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/views.py) (API chat endpoints), [`apichat/utils/main3.py`](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/utils/main3.py) (LangGraph workflow), [`apichat/utils/retriever_hybrid.py`](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/utils/retriever_hybrid.py) (Hybrid retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_django["Django application"]
  node_runtime["Django runtime<br/>Django entry points<br/>[manage.py]"]
  node_routing["Project routing &amp; settings<br/>Django configuration<br/>[urls.py]"]
  node_main["Product UI &amp; chat<br/>Django app<br/>[views.py]"]
  node_main_models[("Product schema<br/>Django models<br/>[models.py]")]
  node_auth["Identity &amp; approval<br/>Django app<br/>[views.py]"]
  node_auth_models[("User schema<br/>Django models<br/>[models.py]")]
end

subgraph group_rag["API assistant RAG"]
  node_api_endpoints["API chat endpoints<br/>Django app<br/>[views.py]"]
  node_rag_workflow{{"LangGraph workflow<br/>RAG orchestration<br/>[main3.py]"}}
  node_hybrid_retrieval["Hybrid retrieval<br/>semantic + BM25"]
  node_api_vectors[("API document vectors<br/>Chroma datastore<br/>[vector_db.py]")]
  node_qa_vectors[("Generated QA vectors<br/>Chroma datastore<br/>[vector_db_qa.py]")]
  node_openai(("OpenAI GPT-4o<br/>external model API"))
  node_media["Upload &amp; speech adapters<br/>media integration<br/>[aws_s3_service.py]"]
end

subgraph group_internal["Internal sLLM chat"]
  node_internal_endpoints["Internal chat integration<br/>Django app<br/>[views.py]"]
  node_sllm_client["Remote sLLM client<br/>model client<br/>[sllm.py]"]
  node_qwen(("Qwen3-8B service<br/>RunPod vLLM/FastAPI"))
end

subgraph group_infra["Deployment &amp; infrastructure"]
  node_mysql[("MySQL<br/>system of record")]
  node_s3[("AWS S3<br/>object storage")]
  node_container["Container deployment<br/>Docker / Elastic Beanstalk"]
  node_ci["Image build CI<br/>GitHub Actions<br/>[docker-image.yml]"]
end

node_runtime -->|"loads"| node_routing
node_routing -->|"routes browser UI"| node_main
node_routing -->|"routes account flows"| node_auth
node_routing -->|"routes API chat"| node_api_endpoints
node_routing -->|"routes internal chat"| node_internal_endpoints
node_main -->|"persists product data"| node_main_models
node_auth -->|"manages users"| node_auth_models
node_main_models -->|"stored in"| node_mysql
node_auth_models -->|"stored in"| node_mysql
node_api_endpoints -->|"submits chat requests"| node_rag_workflow
node_api_endpoints -->|"handles image and voice input"| node_media
node_media -->|"stores uploads"| node_s3
node_rag_workflow -->|"retrieves evidence"| node_hybrid_retrieval
node_hybrid_retrieval -->|"semantic source"| node_api_vectors
node_hybrid_retrieval -->|"QA source"| node_qa_vectors
node_rag_workflow -->|"generates and evaluates"| node_openai
node_internal_endpoints -->|"reads role and department"| node_auth_models
node_internal_endpoints -->|"invokes authorized chat"| node_sllm_client
node_sllm_client -->|"remote inference"| node_qwen
node_ci -->|"builds image"| node_container
node_container -->|"serves application"| node_runtime

click node_runtime "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/manage.py"
click node_routing "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/codenova/urls.py"
click node_main "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/main/views.py"
click node_main_models "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/main/models.py"
click node_auth "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/uauth/views.py"
click node_auth_models "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/uauth/models.py"
click node_api_endpoints "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/views.py"
click node_rag_workflow "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/utils/main3.py"
click node_hybrid_retrieval "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/utils/retriever_hybrid.py"
click node_api_vectors "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/utils/vector_db.py"
click node_qa_vectors "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/utils/vector_db_qa.py"
click node_media "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/aws_s3_service.py"
click node_internal_endpoints "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/internal/views.py"
click node_sllm_client "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/internal/utils/sllm.py"
click node_container "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/Dockerfile"
click node_ci "https://github.com/rwr9857/skn14-final-1team-web/blob/develop/.github/workflows/docker-image.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runtime,node_routing,node_main,node_main_models,node_auth,node_auth_models toneBlue
class node_api_endpoints,node_rag_workflow,node_hybrid_retrieval,node_api_vectors,node_qa_vectors,node_openai,node_media toneAmber
class node_internal_endpoints,node_sllm_client,node_qwen toneMint
class node_mysql,node_s3,node_container,node_ci toneRose
```

## Components

### Django application

- [Django runtime](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/manage.py): Django entry points · WSGI/ASGI process entry points. · `manage.py`
- [Project routing & settings](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/codenova/urls.py): Django configuration · `codenova/urls.py`
- [Product UI & chat](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/main/views.py): Django app · Browser views plus chat, community, and saved-content persistence. · `main/views.py`
- [Product schema](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/main/models.py): Django models · Sessions, messages, images, cards, API keys, and community records. · `main/models.py`
- [Identity & approval](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/uauth/views.py): Django app · Signup, login, approval, department, and rank. · `uauth/views.py`
- [User schema](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/uauth/models.py): Django models · `uauth/models.py`

### API assistant RAG

- [API chat endpoints](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/views.py): Django app · `apichat/views.py`
- [LangGraph workflow](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/utils/main3.py): RAG orchestration · Classifies requests, preserves context, evaluates answers, and retries retrieval. · `apichat/utils/main3.py`
- [Hybrid retrieval](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/utils/retriever_hybrid.py): semantic + BM25 · Combines BGE-M3 semantic and keyword search. · `apichat/utils/retriever_hybrid.py`
- [API document vectors](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/utils/vector_db.py): Chroma datastore · `apichat/utils/vector_db.py`
- [Generated QA vectors](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/utils/vector_db_qa.py): Chroma datastore · `apichat/utils/vector_db_qa.py`
- **OpenAI GPT-4o**: external model API · Generates grounded API-assistant answers.
- [Upload & speech adapters](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/apichat/aws_s3_service.py): media integration · Stores images and transcribes voice before RAG processing. · `apichat/aws_s3_service.py`

### Internal sLLM chat

- [Internal chat integration](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/internal/views.py): Django app · Applies authenticated department and role access constraints. · `internal/views.py`
- [Remote sLLM client](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/internal/utils/sllm.py): model client · `internal/utils/sllm.py`
- **Qwen3-8B service**: RunPod vLLM/FastAPI · Selects direct conversation or authorized document-search tools.

### Deployment & infrastructure

- **MySQL**: system of record · Runs separately on EC2.
- **AWS S3**: object storage · Stores chat and profile media.
- [Container deployment](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/Dockerfile): Docker / Elastic Beanstalk · Production Django serving via Gunicorn/Uvicorn. · `Dockerfile`
- [Image build CI](https://github.com/rwr9857/skn14-final-1team-web/blob/develop/.github/workflows/docker-image.yml): GitHub Actions · `.github/workflows/docker-image.yml`

## Connections

- Django runtime → Project routing & settings: loads
- Project routing & settings → Product UI & chat: routes browser UI
- Project routing & settings → Identity & approval: routes account flows
- Project routing & settings → API chat endpoints: routes API chat
- Project routing & settings → Internal chat integration: routes internal chat
- Product UI & chat → Product schema: persists product data
- Identity & approval → User schema: manages users
- Product schema → MySQL: stored in
- User schema → MySQL: stored in
- API chat endpoints → LangGraph workflow: submits chat requests
- API chat endpoints → Upload & speech adapters: handles image and voice input
- Upload & speech adapters → AWS S3: stores uploads
- LangGraph workflow → Hybrid retrieval: retrieves evidence
- Hybrid retrieval → API document vectors: semantic source
- Hybrid retrieval → Generated QA vectors: QA source
- LangGraph workflow → OpenAI GPT-4o: generates and evaluates
- Internal chat integration → User schema: reads role and department
- Internal chat integration → Remote sLLM client: invokes authorized chat
- Remote sLLM client → Qwen3-8B service: remote inference
- Image build CI → Container deployment: builds image
- Container deployment → Django runtime: serves application
