Project structure¶
Pagelore/
├── assets/ # logo
├── docker/
│ ├── docker-compose.yml # API + Postgres (pgvector) + Qdrant + pgAdmin
│ ├── pagelore/ # Dockerfile and entrypoint (migrates, then starts)
│ ├── db/initdb/ # Postgres init: pgvector extension
│ └── env/ # .env.example.app, .env.example.postgres
├── docs/ # This documentation site (MkDocs Material)
├── src/
│ ├── main.py # FastAPI app; shared clients created at startup
│ ├── routes/ # HTTP layer: endpoints, schemas, error mapping
│ ├── controllers/ # Use cases: ingest, process, retrieve, evaluate, jobs, ...
│ ├── models/
│ │ ├── db_schemes/pagelore # SQLAlchemy tables and Alembic migrations
│ │ ├── metadata_filter.py # Metadata validation and the filter language
│ │ └── *Model.py # Data access for projects, documents, chunks, API keys, jobs
│ ├── stores/
│ │ ├── loaders/ # Text extraction, one loader per format (or Docling)
│ │ ├── chunking/ # The chunking strategies
│ │ ├── embeddings/ # Embedding providers
│ │ ├── vectordb/ # Vector DB providers
│ │ ├── rerankers/ # Reranker providers
│ │ ├── llm/ # LLM providers (internal work)
│ │ └── sources/ # Web crawler (SSRF-safe) and S3 reader
│ ├── utils/config.py # Settings (pydantic-settings)
│ └── .env.example # Every setting, documented
├── scripts/
│ └── compare_extractors.py # Native vs Docling retrieval on your documents
├── tests/
│ ├── unit/ # Pure logic, providers with mocked clients
│ └── integration/ # The API against Postgres and embedded vector DBs
├── .github/
│ ├── workflows/ # CI: tests, the Docker image and the docs site
│ └── scripts/ # The Docker image smoke test
├── mkdocs.yml # Docs site configuration
├── run.sh # Starts the app locally or in Docker (./run.sh --help)
└── pyproject.toml # Dependencies and optional extras (uv)
Layers¶
flowchart TB
R["routes/<br/>validate requests, map errors to status codes"]
C["controllers/<br/>the logic; sync work runs in a thread pool"]
M["models/<br/>Postgres data access"]
S["stores/<br/>vector DBs, embeddings, rerankers, LLMs,<br/>loaders, chunkers, sources"]
R --> C
C --> M
C --> S
Each layer only talks to the layer below it:
- Routes validate requests with Pydantic schemas and map errors to status codes. They hold no logic.
- Controllers hold the use cases. The code is synchronous, and the
async endpoints run it with
run_in_threadpool, so a slow provider never blocks the event loop. Background jobs run the same controllers in the job worker's threads (JobWorker,JobController). - Models are the Postgres tables (SQLAlchemy) and their data access.
- Stores wrap the external systems behind one interface per kind.
Adding a provider¶
Every kind of store has an interface, an enum and a factory:
| Kind | Interface | Factory |
|---|---|---|
| Vector DB | stores/vectordb/VectorDBInterface.py |
VectorDBProviderFactory.py |
| Embeddings | stores/embeddings/EmbeddingInterface.py |
EmbeddingProviderFactory.py |
| Reranker | stores/rerankers/RerankerInterface.py |
RerankerProviderFactory.py |
| LLM | stores/llm/LLMInterface.py |
LLMProviderFactory.py |
| File format | stores/loaders/LoaderInterface.py |
LoaderFactory.py |
So a new vector DB, embedding provider, reranker, LLM or file format is a new provider class plus a factory entry. Factories import provider modules lazily, so a missing optional extra only matters when that provider is selected, and the error names the extra to install.
Startup¶
src/main.py creates one client of each kind when the app starts, shared
by every request:
- Check that Postgres is reachable and migrated.
- Connect to the vector DB.
- Create the embedding client and learn its vector dimension (this loads a local model, or sends one probe request).
- Create the reranker, if configured. A local reranker loads its model.
- Create the LLM client, if configured. The model is first called by a job, not at startup.
A misconfiguration, an unreachable service or a missing model stops the app at startup with a clear message, instead of failing on the first request.