Machine-readable operating guidance for AI coding agents in hotosm/login.
Project: HOTOSM Login (SSO)
Accountability: human maintainers are responsible for all merged changes.
This repository is a multi-service login platform, not a single backend app.
Primary components:
backend/: FastAPI service (auth endpoints, profile endpoints, admin proxy routes)frontend/: React + Vite SPA for login/profile UXauth-libs/: shared auth librariesauth-libs/python/:hotosm_authcore + integrations for FastAPI, Django, and Litestar (hotosm_auth_litestar)auth-libs/web-component/:@hotosm/hanko-authweb component source + dist bundles
osm-userinfo/: Go microservice to adapt OSM user info into OIDC-like claims for Hankodocker-compose.yml: service orchestration (Traefik, Hanko, Postgres, backend, frontend, osm-userinfo)
Backend structure to follow:
- Routes in
backend/app/api/routes/ - Config in
backend/app/core/ - Database models/session in
backend/app/db/ - Request/response schemas in
backend/app/schemas/
Before non-trivial changes, read:
README.md- Relevant docs under
docs/src/(especiallyoverview.md,integration-guide.md) - Component-level docs:
auth-libs/README.mdauth-libs/python/README.mdauth-libs/web-component/README.mdosm-userinfo/README.md
Notes:
- There is no local
docs/decisions/tree in this repo. - High-level ADR context is linked from
README.md(external docs).
Use this execution loop:
- Discover
- Inspect existing code paths first.
- Preserve established patterns per component (FastAPI in backend, React in frontend).
- Plan
- Keep edits minimal and task-scoped.
- Identify tests/checks to run before coding.
- Implement
- Keep FastAPI route handlers thin where possible.
- Prefer shared logic in reusable modules/services when adding cross-route behavior.
- For auth-libs, keep framework integrations aligned (FastAPI/Django/Litestar).
- Verify
- Run focused checks first, then broader checks if needed.
- Report what was run and what could not be run.
- Summarize
- List changed files and behavior impact.
- List risks/follow-ups.
For larger changes, prefer incremental, reviewable patches.
Root-level Docker/dev stack:
cp .env.example .env
docker compose --profile dev up --buildProduction-like local stack:
docker compose --profile prod up --buildBackend local development:
cd backend
uv sync
uv run alembic upgrade head
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reloadBackend checks:
cd backend
uv run ruff check app
uv run ruff format app
uv run pytest -vFrontend local development:
cd frontend
pnpm install
pnpm devFrontend checks:
cd frontend
pnpm lint
pnpm build
pnpm testAuth-libs Python local checks:
cd auth-libs/python
uv sync
uv run pytest -vPre-commit hooks (repo root):
pre-commit install
pre-commit run --all-filesHook config is in .pre-commit-config.yaml and includes commitizen, ruff/ruff-format, uv-lock, pyupgrade, complexipy, typos, bashate, shellcheck, actionlint, and markdownlint.
- Prefer explicit, readable code over clever abstractions.
- Keep functions and endpoints focused.
- Reuse existing schemas/models/config patterns.
- Avoid comments unless intent is non-obvious.
- Keep framework boundaries clear:
- FastAPI-specific logic in
backend/ - reusable auth primitives in
auth-libs/python/src/hotosm_auth - framework adapters in
hotosm_auth_fastapi,hotosm_auth_django,hotosm_auth_litestar
- FastAPI-specific logic in
Frontend standards:
- Keep React components predictable and typed.
- Prefer existing styling and state-management patterns already used in
frontend/src/.
All new behavior should include verification.
- Backend API behavior: add/update pytest tests (expected location:
backend/app/tests/per backend pytest config). - Frontend behavior: add/update Vitest tests when logic/UI behavior changes.
- Auth-libs behavior: add/update tests under
auth-libs/python/tests/. - Cover both success and failure paths where practical.
- Do not delete/disable tests just to make checks pass.
If test execution is blocked by environment constraints, report exact blockers.
Never:
- Commit
.envvalues, secrets, or credentials - Hardcode tokens/client secrets
- Bypass auth checks or admin guards
- Introduce unsafe SQL construction
Ask first before:
- Introducing new dependencies
- Changing auth/session/security behavior
- DB schema changes and migrations
- Deployment workflow changes (
.github/workflows/, infra behavior)
Backend uses Alembic:
- Migration config:
backend/alembic.ini - Migration scripts:
backend/alembic/versions/
When schema changes are required:
- Add/adjust Alembic migration(s) in
backend/alembic/versions/ - Keep SQLAlchemy models in sync (
backend/app/db/models.py) - Verify migration upgrade path locally when feasible
Default edit scope (unless task requires otherwise):
backend/**frontend/**auth-libs/**docs/**osm-userinfo/**AGENTS.md
Treat as sensitive; modify only when explicitly requested:
.env.github/workflows/**chart/**- deployment scripts under
scripts/
Avoid editing generated/local artifacts unless the task is specifically about them:
**/__pycache__/**/.pytest_cache/**/.ruff_cache/- compiled/built outputs in
dist/directories (except when task is to update distributable artifacts)
- Use Conventional Commits.
- Keep dependency/version diffs minimal and justified.
- Do not perform opportunistic upgrades unrelated to the task.
For auth-libs Python changes:
- Keep
auth-libs/python/pyproject.tomland lockfile consistent. - Ensure new integrations stay compatible with declared optional extras (
fastapi,django,litestar).
If commits are requested, include a model/tool trailer, e.g.:
Assisted-by: Codex (GPT-5)
- Mixing framework concerns (e.g., app-specific logic leaking into core auth-lib modules)
- Reimplementing logic already available in
hotosm_authcore - Large cross-directory refactors without staged validation
- Making deployment/workflow changes as part of unrelated feature work
- Adding auth bypasses for convenience in production paths
A change is done when all are true:
- Behavior is implemented in code.
- Relevant tests/checks were run, or blockers are explicitly reported.
- Lint/format hooks for changed scope are satisfied.
- Summary includes changed files, impact, and known risks/follow-up.