# kotorcat/expired-bread architecture

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

- Interactive diagram: https://gitdiagram.com/kotorcat/expired-bread
- Repository: https://github.com/kotorcat/expired-bread

## Overview

Expired Bread is a Django document-management application. Users upload PDF/DOCX files, the system extracts text or falls back to GigaChat Vision, AI results enter a human review step, and confirmed documents become searchable and usable for document-grounded Q&A. The graph preserves these stages, persistence, and the separate search and Q&A capabilities. Relationships are based on the README and excerpted source; template rendering and some UI wiring are documented or visible only by path, so uncertain links are omitted.

Main entry points: [`documents/views.py`](https://github.com/kotorcat/expired-bread/blob/main/documents/views.py) (Document views), [`documents/services/document_service.py`](https://github.com/kotorcat/expired-bread/blob/main/documents/services/document_service.py) (Processing workflow), [`documents/services/llm.py`](https://github.com/kotorcat/expired-bread/blob/main/documents/services/llm.py) (GigaChat analysis), [`documents/services/search_service.py`](https://github.com/kotorcat/expired-bread/blob/main/documents/services/search_service.py) (Document search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_views["Document views<br/>[views.py]"]
  node_forms["Upload and review forms<br/>[forms.py]"]
end

subgraph group_processing["Document processing"]
  node_orchestrator["Processing workflow"]
  node_extractors["PDF/DOCX extraction<br/>[extractors.py]"]
  node_llm["GigaChat analysis<br/>[llm.py]"]
end

subgraph group_knowledge["Search and Q&amp;A"]
  node_search["Document search<br/>[search_service.py]"]
  node_normalization["Search normalization<br/>[normalization.py]"]
  node_qa["Question answering<br/>[qa_service.py]"]
end

subgraph group_storage["Document data"]
  node_records[("Document records<br/>[models.py]")]
  node_file_store[("Original files<br/>[models.py]")]
end

node_user(("User"))
node_gigachat{{"GigaChat service"}}

node_user -->|"uses"| node_views
node_views -->|"validates"| node_forms
node_views -->|"reads/writes"| node_records
node_views -->|"starts processing"| node_orchestrator
node_orchestrator -->|"updates"| node_records
node_orchestrator -->|"reads file"| node_file_store
node_orchestrator -->|"extracts text"| node_extractors
node_orchestrator -->|"analyzes text"| node_llm
node_orchestrator -->|"vision fallback"| node_llm
node_llm -->|"requests analysis"| node_gigachat
node_views -->|"searches"| node_search
node_search -->|"queries"| node_records
node_views -->|"asks question"| node_qa
node_qa -->|"finds candidates"| node_search
node_qa -->|"sends context"| node_llm
node_normalization -.->|"prepares text"| node_search

click node_views "https://github.com/kotorcat/expired-bread/blob/main/documents/views.py"
click node_forms "https://github.com/kotorcat/expired-bread/blob/main/documents/forms.py"
click node_records "https://github.com/kotorcat/expired-bread/blob/main/documents/models.py"
click node_file_store "https://github.com/kotorcat/expired-bread/blob/main/documents/models.py"
click node_orchestrator "https://github.com/kotorcat/expired-bread/blob/main/documents/services/document_service.py"
click node_extractors "https://github.com/kotorcat/expired-bread/blob/main/documents/services/extractors.py"
click node_llm "https://github.com/kotorcat/expired-bread/blob/main/documents/services/llm.py"
click node_search "https://github.com/kotorcat/expired-bread/blob/main/documents/services/search_service.py"
click node_normalization "https://github.com/kotorcat/expired-bread/blob/main/documents/services/normalization.py"
click node_qa "https://github.com/kotorcat/expired-bread/blob/main/documents/services/qa_service.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_views,node_forms,node_user toneBlue
class node_orchestrator,node_extractors,node_llm toneAmber
class node_search,node_normalization,node_qa toneMint
class node_records,node_file_store toneRose
class node_gigachat toneIndigo
```

## Components

### Web interface

- [Document views](https://github.com/kotorcat/expired-bread/blob/main/documents/views.py): `documents/views.py`
- [Upload and review forms](https://github.com/kotorcat/expired-bread/blob/main/documents/forms.py): `documents/forms.py`

### Document processing

- [Processing workflow](https://github.com/kotorcat/expired-bread/blob/main/documents/services/document_service.py): `documents/services/document_service.py`
- [PDF/DOCX extraction](https://github.com/kotorcat/expired-bread/blob/main/documents/services/extractors.py): `documents/services/extractors.py`
- [GigaChat analysis](https://github.com/kotorcat/expired-bread/blob/main/documents/services/llm.py): `documents/services/llm.py`

### Search and Q&A

- [Document search](https://github.com/kotorcat/expired-bread/blob/main/documents/services/search_service.py): `documents/services/search_service.py`
- [Search normalization](https://github.com/kotorcat/expired-bread/blob/main/documents/services/normalization.py): `documents/services/normalization.py`
- [Question answering](https://github.com/kotorcat/expired-bread/blob/main/documents/services/qa_service.py): `documents/services/qa_service.py`

### Document data

- [Document records](https://github.com/kotorcat/expired-bread/blob/main/documents/models.py): `documents/models.py`
- [Original files](https://github.com/kotorcat/expired-bread/blob/main/documents/models.py): `documents/models.py`

### Other components

- **User**
- **GigaChat service**

## Connections

- User → Document views: uses (evidence: `README.md`)
- Document views → Upload and review forms: validates (evidence: `documents/views.py`)
- Document views → Document records: reads/writes (evidence: `documents/views.py`)
- Document views → Processing workflow: starts processing (evidence: `documents/views.py`)
- Processing workflow → Document records: updates (evidence: `documents/services/document_service.py`)
- Processing workflow → Original files: reads file (evidence: `documents/services/document_service.py`)
- Processing workflow → PDF/DOCX extraction: extracts text (evidence: `documents/services/document_service.py`)
- Processing workflow → GigaChat analysis: analyzes text (evidence: `documents/services/document_service.py`)
- Processing workflow → GigaChat analysis: vision fallback (evidence: `documents/services/document_service.py`)
- GigaChat analysis → GigaChat service: requests analysis (evidence: `README.md`)
- Document views → Document search: searches (evidence: `documents/views.py`)
- Document search → Document records: queries (evidence: `documents/services/search_service.py`)
- Document views → Question answering: asks question (evidence: `documents/views.py`)
- Question answering → Document search: finds candidates (evidence: `documents/services/qa_service.py`)
- Question answering → GigaChat analysis: sends context (evidence: `documents/services/qa_service.py`)
- Search normalization → Document search: prepares text
