Primary onboarding source. Trust this file first; search the repo only when information here is missing, stale, or contradicted by runtime output.
Lumigen is a local-first AI image studio (FastAPI monolith) for image generation, gallery management, metadata sidecars, and optional upscaling.
- Main runtime path: route (
/generate) →GenerationService→ProviderRegistry/adapter →StorageService+ThumbnailService+SidecarService→ DBAssetrows. - Stack: Python 3.12+, FastAPI, Jinja2 + HTMX, SQLite, SQLAlchemy 2, Alembic.
- Tooling:
ruff,djlint,eslint,stylelint,pytest,@playwright/test. - Dev server:
http://127.0.0.1:8010.
- Project type: server-rendered web app + API in one Python service.
- Size/layout: single backend app under
app/, migrations underalembic/, tests undertests/, helper scripts underscripts/. - Runtimes: Python
3.12+, Node (CI uses Node 20).
Run all commands from the repository root.
# 1. Create/activate a virtualenv
# 2. Install Python deps
pip install -r requirements.txt
# 3. Apply migrations
alembic upgrade head
# 4. Install Node deps (required for JS/CSS lint and Playwright)
npm.cmd ci # use .cmd on Windows PowerShell
# 5. Install Playwright browsers (once)
npx.cmd playwright install --with-deps chromiumIf linters are missing locally:
python -m pip install ruff djlintUse .cmd shims on Windows PowerShell:
npm.cmd cinpx.cmd eslint app/web/static/js/npx.cmd stylelint "app/web/static/css/app.css"npx.cmd playwright test
python -m app.main# Unit tests
python -m pytest -q tests/unit
# Route + UI route tests
python -m pytest -q tests/routes tests/ui_routes
# Playwright e2e (requires npm.cmd ci + browser install once)
npx.cmd playwright test
npx.cmd playwright test --ui # interactive runnerpython -m ruff check app/ # Python lint
djlint app/web/templates/ --lint # template lint
npx.cmd eslint app/web/static/js/ # JS lint
npx.cmd stylelint "app/web/static/css/app.css" # CSS lintalembic upgrade headpython -m pytest -q tests/unitpython -m pytest -q tests/routes tests/ui_routesnpx.cmd playwright testpython -m ruff check app/djlint app/web/templates/ --lintnpx.cmd eslint app/web/static/js/npx.cmd stylelint "app/web/static/css/app.css"
.github/workflows/lint.yml— lint only (ruff, djlint, eslint, stylelint)..github/workflows/e2e.yml— Playwright e2e (chromium only); uploads HTML report artifact.
| Area | Path |
|---|---|
| Route handlers + DI wiring | app/main.py |
| SQLAlchemy schema | app/db/models.py |
| DB helpers / queries | app/db/crud.py |
| Engine / session init | app/db/engine.py |
| Schema migrations | alembic/versions/* |
| Generation orchestration | app/services/generation_service.py |
| Atomic file IO + path safety | app/services/storage_service.py |
| Sidecar contract | app/services/sidecar_service.py |
| Provider registry + policies | app/providers/registry.py |
| Provider HTTP adapters | app/providers/*_adapter.py |
| Server-rendered templates | app/web/templates/ |
| Client JavaScript | app/web/static/js/ |
| App-wide CSS | app/web/static/css/app.css |
- Prefer service-layer changes over adding business logic in
app/main.py. - Schema changes: update
app/db/models.pyand add a matching Alembic migration. - Provider logic stays in adapters; orchestration/policies stay in
ProviderRegistry. - All file writes go through
StorageService— do not bypass path-safety checks. - No inline JS or CSS in templates; use
app/web/static/js/*andapp/web/static/css/app.css. - Add/adjust tests for every backend or UI behavior change.
- Tailwind theming: use class-based dark mode only. Do not introduce custom light/dark override systems. Follow Tailwind theme customization.
- Before creating a release, update the version number in the
VERSIONfile located in the project root. - Alternatively, use the provided script:
python scripts/update_version.py <new_version>
- Every public Python class must have a docstring describing its purpose.
- Every public method/function (not prefixed with
_) must have a docstring covering what it does, key parameters, and return value (if non-obvious). - Private helpers (
_-prefixed) should be documented when logic is non-trivial. - Follow PEP 257: triple double-quotes, capital first letter, ends with a period.
- Always include or update docstrings when adding or modifying a class or public method.
- Config:
playwright.config.js(root) —chromiumproject,setupproject (tests/e2e/auth.setup.js),webServeron port 8765 with isolated SQLite in/tmp/lumigen-e2e/. - Test files:
tests/e2e/*.spec.js(one per feature area). - Auth:
auth.setup.jscreates the first admin via onboarding and saves session toplaywright/.auth/admin.json; all specs reuse it viastorageState. - To add a test: create
tests/e2e/<feature>.spec.js, import{ test, expect }from@playwright/test.
.env.examplehas local-dev defaults.- Production needs a strong
SESSION_SECRET_KEY. - API key encryption requires
PROVIDER_CONFIG_KEY(generate viascripts/generate_provider_key.ps1or.sh). - Run Alembic from repo root (
alembic.iniusessqlite:///./data/app.db).
For implementing or understanding image requests to various providers, refer to:
- OpenRouter: https://openrouter.ai/docs/guides/overview/multimodal/image-generation
- FAL.AI: https://fal.ai/models/fal-ai/nano-banana-2/api
- BFL: https://docs.bfl.ai/quick_start/generating_images#primary-global-endpoint
- OpenAI: https://developers.openai.com/api/docs/guides/image-generation
- Google Gemini: https://ai.google.dev/gemini-api/docs/image-generation
.github/ alembic/ app/ tests/ scripts/ docs/ docker/ data/
README.md requirements.txt pyproject.toml pytest.ini alembic.ini
package.json eslint.config.mjs Dockerfile .stylelintrc.json playwright.config.js
Only search the repo if one of these is true:
- A command/path in this file no longer exists.
- Runtime output contradicts this document.
- The requested change touches an area not mapped in the architecture map.