# codewithdark-git/darkgpt architecture

> Architecture diagram of the GitHub repository codewithdark-git/darkgpt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codewithdark-git/darkgpt
- Repository: https://github.com/codewithdark-git/darkgpt

## Overview

This Flask backend accepts document uploads and chat queries: the upload endpoint saves a file temporarily and asks the vector-store component to process it, while the chat endpoint passes a query to an LLM pipeline and returns its response. Separate audio and video handlers transcribe uploads with Whisper; a text pipeline also delegates embedding work to the vector store. The document model suggests a database-backed capability, but its database setup is not present in the supplied tree. The README is empty, so unsampled subsystem behavior is not inferred.

Main entry points: [`backend/app/api/upload.py`](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/api/upload.py) (Document Upload), [`backend/app/api/endpoints.py`](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/api/endpoints.py) (Chat Endpoint), [`backend/app/app.py`](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/app.py) (Flask App), [`backend/app/core/llm_pipeline.py`](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/core/llm_pipeline.py) (LLM Pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_app["Flask App<br/>[app.py]"]
  node_upload["Document Upload<br/>[upload.py]"]
  node_chat["Chat Endpoint<br/>[endpoints.py]"]
end

subgraph group_core["Query and Documents"]
  node_llm["LLM Pipeline<br/>[llm_pipeline.py]"]
  node_vector["Vector Store<br/>[vector_store.py]"]
  node_text["Text Pipeline<br/>[text_pipeline.py]"]
end

subgraph group_media["Media and Data"]
  node_document["Document Model<br/>[document.py]"]
  node_video["Video Transcription<br/>[video_handler.py]"]
  node_audio["Audio Transcription<br/>[text_to_speech.py]"]
end

node_user(("Client"))
node_groq["Groq Model"]
node_whisper["OpenAI Whisper"]

node_app -->|"registers route"| node_upload
node_app -->|"registers route"| node_chat
node_user -->|"uploads document"| node_upload
node_user -->|"sends query"| node_chat
node_upload -->|"adds document"| node_vector
node_chat -->|"processes query"| node_llm
node_llm -->|"generates response"| node_groq
node_text -->|"stores embedding"| node_vector
node_video -->|"transcribes video"| node_whisper
node_audio -->|"transcribes audio"| node_whisper

click node_app "https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/app.py"
click node_upload "https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/api/upload.py"
click node_chat "https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/api/endpoints.py"
click node_llm "https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/core/llm_pipeline.py"
click node_vector "https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/core/vector_store.py"
click node_text "https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/core/text_pipeline.py"
click node_document "https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/models/document.py"
click node_video "https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/services/video_handler.py"
click node_audio "https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/services/text_to_speech.py"

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_app,node_upload,node_chat,node_user toneBlue
class node_llm,node_vector,node_text toneAmber
class node_document,node_video,node_audio toneMint
class node_groq,node_whisper toneIndigo
```

## Components

### HTTP API

- [Flask App](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/app.py): `backend/app/app.py`
- [Document Upload](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/api/upload.py): `backend/app/api/upload.py`
- [Chat Endpoint](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/api/endpoints.py): `backend/app/api/endpoints.py`

### Query and Documents

- [LLM Pipeline](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/core/llm_pipeline.py): `backend/app/core/llm_pipeline.py`
- [Vector Store](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/core/vector_store.py): `backend/app/core/vector_store.py`
- [Text Pipeline](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/core/text_pipeline.py): `backend/app/core/text_pipeline.py`

### Media and Data

- [Document Model](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/models/document.py): `backend/app/models/document.py`
- [Video Transcription](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/services/video_handler.py): `backend/app/services/video_handler.py`
- [Audio Transcription](https://github.com/codewithdark-git/darkgpt/blob/main/backend/app/services/text_to_speech.py): `backend/app/services/text_to_speech.py`

### Other components

- **Client**
- **Groq Model**
- **OpenAI Whisper**

## Connections

- Flask App → Document Upload: registers route (evidence: `backend/app/app.py`)
- Flask App → Chat Endpoint: registers route (evidence: `backend/app/app.py`)
- Client → Document Upload: uploads document (evidence: `backend/app/api/upload.py`)
- Client → Chat Endpoint: sends query (evidence: `backend/app/api/endpoints.py`)
- Document Upload → Vector Store: adds document (evidence: `backend/app/api/upload.py`)
- Chat Endpoint → LLM Pipeline: processes query (evidence: `backend/app/api/endpoints.py`)
- LLM Pipeline → Groq Model: generates response (evidence: `backend/app/core/llm_pipeline.py`)
- Text Pipeline → Vector Store: stores embedding (evidence: `backend/app/core/text_pipeline.py`)
- Video Transcription → OpenAI Whisper: transcribes video (evidence: `backend/app/services/video_handler.py`)
- Audio Transcription → OpenAI Whisper: transcribes audio (evidence: `backend/app/services/text_to_speech.py`)
