Repository navigation
API Development
English · 한국어
Applies to Miroven-API 0.1.0, independently of client v1.1.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.
Copy .env.example to .env only if no .env exists, then:
docker compose up -d --build --waitAPI: 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 --waitApp: http://localhost:8080. See client development for browser integration checks.
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.pyprepare_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.
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 typecheckDatabase 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.serveruv run python -m app.workerSee deployment, operations, and validation boundaries. Keep API and client format versions distinct.
- Client development · 클라이언트 개발
- Self-hosting · 자체 호스팅
- PWA, offline use, and updates · PWA·오프라인·업데이트
- Client performance · 클라이언트 성능
- Architecture · 아키텍처
- Cryptographic format · 암호화 형식
- Image processing · 사진 처리
- Security model · 보안 경계
- Product principles · 제품 원칙
- Dependency licenses · 의존성 라이선스
- Account and sync · 계정과 동기화
- Backup and recovery · 백업과 복구
- Entry quotes · 기록 인용
- Profile document · 프로필 문서