# teeraphat66050204/special-problem-fullstack architecture

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

- Interactive diagram: https://gitdiagram.com/teeraphat66050204/special-problem-fullstack
- Repository: https://github.com/teeraphat66050204/special-problem-fullstack

## Overview

This is Phase 1 of a PDF-to-Wiki backend: it defines document, wiki-version, and chunk schemas, plus a standalone digital-PDF text extractor. The intended user flow is upload and preserve a PDF, extract page-aware text, persist document metadata, then generate, review, publish, chunk, and eventually embed/search the wiki. Only the schema and extractor are implemented here; later workflow stages are documented handoffs, not inspected runtime components.

Main entry points: [`app/models/entities.py`](https://github.com/teeraphat66050204/special-problem-fullstack/blob/main/app/models/entities.py) (Document metadata), [`app/services/pdf_extractor.py`](https://github.com/teeraphat66050204/special-problem-fullstack/blob/main/app/services/pdf_extractor.py) (PDF text extractor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["PDF intake"]
  node_upload["Upload endpoint"]
  node_file["Original PDF"]
  node_extract["PDF text extractor<br/>[pdf_extractor.py]"]
  node_document["Document metadata<br/>[entities.py]"]
end

subgraph group_content["Wiki content"]
  node_wiki_generator["Wiki generator"]
  node_review["Review and publish"]
  node_wiki_page["Versioned WikiPage<br/>[entities.py]"]
end

subgraph group_retrieval["Retrieval handoff"]
  node_chunking["Chunking"]
  node_chunk["Provenance chunks<br/>[entities.py]"]
  node_embedding["Embedding handoff"]
  node_search["Semantic search"]
end

node_user(("Uploader"))

node_user -.->|"submits PDF"| node_upload
node_upload -.->|"saves original"| node_file
node_upload -.->|"calls extractor"| node_extract
node_extract -.->|"returns text"| node_document
node_upload -.->|"persists metadata"| node_document
node_document -.->|"feeds generation"| node_wiki_generator
node_wiki_generator -.->|"generates draft"| node_review
node_review -.->|"stores versions"| node_wiki_page
node_wiki_page -.->|"feeds chunking"| node_chunking
node_chunking -.->|"creates chunks"| node_chunk
node_chunk -.->|"feeds embeddings"| node_embedding
node_embedding -.->|"enables retrieval"| node_search
node_document -->|"owns versions"| node_wiki_page
node_document -->|"owns chunks"| node_chunk
node_wiki_page -->|"may scope chunks"| node_chunk

click node_extract "https://github.com/teeraphat66050204/special-problem-fullstack/blob/main/app/services/pdf_extractor.py"
click node_document "https://github.com/teeraphat66050204/special-problem-fullstack/blob/main/app/models/entities.py"
click node_wiki_page "https://github.com/teeraphat66050204/special-problem-fullstack/blob/main/app/models/entities.py"
click node_chunk "https://github.com/teeraphat66050204/special-problem-fullstack/blob/main/app/models/entities.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_upload,node_file,node_extract,node_document toneBlue
class node_wiki_generator,node_review,node_wiki_page toneAmber
class node_chunking,node_chunk,node_embedding,node_search toneMint
class node_user toneIndigo
```

## Components

### PDF intake

- **Upload endpoint**
- **Original PDF**
- [PDF text extractor](https://github.com/teeraphat66050204/special-problem-fullstack/blob/main/app/services/pdf_extractor.py): `app/services/pdf_extractor.py`
- [Document metadata](https://github.com/teeraphat66050204/special-problem-fullstack/blob/main/app/models/entities.py): `app/models/entities.py`

### Wiki content

- **Wiki generator**
- **Review and publish**
- [Versioned WikiPage](https://github.com/teeraphat66050204/special-problem-fullstack/blob/main/app/models/entities.py): `app/models/entities.py`

### Retrieval handoff

- **Chunking**
- [Provenance chunks](https://github.com/teeraphat66050204/special-problem-fullstack/blob/main/app/models/entities.py): `app/models/entities.py`
- **Embedding handoff**
- **Semantic search**

### Other components

- **Uploader**

## Connections

- Uploader → Upload endpoint: submits PDF (evidence: `README.md`)
- Upload endpoint → Original PDF: saves original (evidence: `README.md`)
- Upload endpoint → PDF text extractor: calls extractor (evidence: `README.md`)
- PDF text extractor → Document metadata: returns text (evidence: `README.md`)
- Upload endpoint → Document metadata: persists metadata (evidence: `README.md`)
- Document metadata → Wiki generator: feeds generation (evidence: `README.md`)
- Wiki generator → Review and publish: generates draft (evidence: `README.md`)
- Review and publish → Versioned WikiPage: stores versions (evidence: `README.md`)
- Versioned WikiPage → Chunking: feeds chunking (evidence: `README.md`)
- Chunking → Provenance chunks: creates chunks (evidence: `README.md`)
- Provenance chunks → Embedding handoff: feeds embeddings (evidence: `README.md`)
- Embedding handoff → Semantic search: enables retrieval (evidence: `README.md`)
- Document metadata → Versioned WikiPage: owns versions (evidence: `app/models/entities.py`)
- Document metadata → Provenance chunks: owns chunks (evidence: `app/models/entities.py`)
- Versioned WikiPage → Provenance chunks: may scope chunks (evidence: `app/models/entities.py`)
