Skip to content

Contributing

Pagelore is open source under the MIT license. Issues and pull requests are welcome on GitHub.

Set up

git clone https://github.com/saqrianoo/Pagelore.git
cd Pagelore
uv sync                      # the app and the dev group (pytest)
cp src/.env.example src/.env

Add the extras for the providers you work on, for example uv sync --extra openai --extra chroma.

Before you open a pull request

  • Run the tests. uv run pytest tests/unit -q needs nothing. For the whole suite, give the tests a throwaway Postgres database (Tests).
  • Keep Python 3.10 working. Pagelore supports Python 3.10 to the latest release, so avoid syntax and standard-library features newer than 3.10 (for example typing.Self or except*), or guard them.
  • Document new settings. Every setting is a field in src/utils/config.py and a commented line in src/.env.example, with its default. Add it to the settings reference too.
  • Add a migration for table changes. Change the SQLAlchemy models, then generate a migration and read what it wrote (Database migrations).
  • Update the docs for anything a user would notice: a new option, provider, file type, endpoint or status code.

How the code is organized

The code has four layers: routes (HTTP), controllers (the use cases), models (Postgres) and stores (vector DBs, embeddings, rerankers, LLMs, loaders, chunkers and sources). Each only calls the layer below it. See Project structure for the tree and for how to add a provider.

A few rules the code follows:

Sync code, run in a thread pool
Controllers and stores are synchronous. The async endpoints call them with run_in_threadpool, so a slow provider never blocks the event loop. Don't add async provider clients.
Optional dependencies are imported lazily
A provider's package is imported when that provider is selected, never at module import. A missing extra then fails with an error that names the extra to install, and only for the user who selected that provider.
Errors map to status codes in one place
Controllers raise the exceptions in src/controllers; src/routes/errors.py turns them into status codes (status codes). Raise the closest existing exception instead of returning an HTTP error from a controller.
Fail at startup, not on the first request
Clients are created once in src/main.py. A misconfiguration should stop the app with a clear message when it starts.
The LLM never answers questions
The optional LLM is for internal work (chunk contexts, test questions). Pagelore returns passages; answering is the calling app's job.

Preview the documentation

The docs are Markdown files in docs/, built with MkDocs Material. Preview them with live reload:

uv run --no-project --with-requirements docs/requirements.txt mkdocs serve

Then open http://127.0.0.1:8000. (Stop the API first, or pass -a 127.0.0.1:8001: both use port 8000.) Before pushing, check that the site builds without warnings:

uv run --no-project --with-requirements docs/requirements.txt mkdocs build --strict

--strict fails on broken links and anchors, as CI does (CI and documentation).