Skip to content
SEUNGWOO CHOI edited this page Oct 18, 2026 · 8 revisions

API development

English · 한국어

Applies to Miroven-API 0.1.0, independently of client v1.0.0. Paths/commands on this page are relative to the API checkout unless stated otherwise. Requires Python 3.12, PostgreSQL, SMTP, Node.js/npm for contract tooling, and Docker Compose with a Linux engine for container development.

Development stack

Copy .env.example to .env only if no .env exists, then:

docker compose up -d --build --wait

API: http://localhost:8000, interactive reference: /docs, Mailpit: http://localhost:8025. Migrations precede API/worker startup. Stop with docker compose down, preserving volumes. The default Compose/Mailpit stack is development-only.

For the client too, place Miroven/ beside Miroven-API/ and run:

docker compose -f compose.yaml -f compose.web.yaml up -d --build --wait

App: http://localhost:8080. See client development for browser integration checks.

PostgreSQL: Compose and disposable host instance

Choose the database setup before configuring .env; the two workflows use different ports and credentials:

Workflow PostgreSQL address Configuration
Compose development stack Host: 127.0.0.1:5432; API/worker containers: db:5432 .env.example targets the host port 5432. Compose overrides the container database URL to db:5432.
Disposable host PostgreSQL 127.0.0.1:55432 scripts/bootstrap_local.py creates .env and .runtime/pg-password with generated credentials. It preserves existing settings and does not start PostgreSQL.

For the disposable workflow, run uv run python scripts/bootstrap_local.py before creating .env, then separately start a disposable PostgreSQL instance on 127.0.0.1:55432 with user miroven and the password saved in .runtime/pg-password. Once it is running:

uv run python scripts/prepare_local_db.py
uv run python scripts/test_local_postgres.py

prepare_local_db.py creates miroven and miroven_test if missing. test_local_postgres.py sets TEST_DATABASE_URL to miroven_test on the same instance and runs pytest. Both helpers reject database URLs outside 127.0.0.1:55432, so they cannot be used unchanged with the Compose database on 5432. For Compose or another instance, create a dedicated _test database, explicitly set TEST_DATABASE_URL with the matching host, port, and credentials, and run uv run pytest -q directly. When switching workflows, review the existing .env URL and credentials; bootstrap will not replace them. Configure SMTP separately for host execution.

Checks and generated contracts

uv sync --locked
uv run pytest -q
uv run ruff check app scripts tests migrations
uv run ruff format --check app scripts tests migrations
uv run python scripts/export_openapi.py --check
npm ci
npm run typecheck

Database tests clear tables. Set TEST_DATABASE_URL to a dedicated database ending in _test; without it, database tests are skipped. Never point it at production or ordinary development data. CI is .github/workflows/ci.yml.

When the contract changes, export it with uv run python scripts/export_openapi.py, run npm run generate, then copy/check it from Miroven/web/ with npm run api:generate and npm run api:check. The API checkout's contracts/openapi.json defines exact request/response types; contracts/api.d.ts and the client's copied types are generated artifacts.

For direct Python execution, configure DB/SMTP in .env, then run migrations, the API, and the worker (the worker in a separate terminal):

uv run alembic upgrade head
uv run python -m app.server
uv run python -m app.worker

See deployment, operations, and validation boundaries. Keep API and client format versions distinct.

Clone this wiki locally