Repository navigation
API Development
English · 한국어
The API and client have independent release cycles. Paths/commands on this page are relative to the API checkout unless stated otherwise. Requires Python 3.12, PostgreSQL, SMTP, Node.js 26.x with its bundled npm for contract tooling, and Docker Compose with a Linux engine for container development.
The root .nvmrc selects Node.js 26, and package.json declares support for >=26 <27. CI reads .nvmrc and selects the latest available 26.x release with check-latest: true. If you use nvm, run these commands from the API checkout before installing contract tools:
nvm install
nvm use
node --version
npm --versionConfirm that Node reports v26.x.y; use the npm bundled with that release. Node.js is needed for development contract tooling only; the API/worker production image uses Python.
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.
Development Compose and newly generated host-local settings explicitly use example.com
in the DEFAULT signup group for synthetic accounts. Existing .env files are preserved:
for host-local tests, explicitly set MIROVEN_EMAIL_DOMAINS_DEFAULT=example.com in the
development server environment and configure local SMTP. Never reuse that override in
production. Tests override the DEFAULT group in their dedicated test settings.
Email policy/catalog maintenance lives in API app/email/README.md. English is canonical;
update locales/en.json, translate corresponding keys in ko.json/ja.json, and run
uv run pytest tests/test_email_policy.py -q for message/placeholder/fallback 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.
For the current API, apply its full Alembic head before serving traffic; the supplied Compose migration service does this automatically. 0004_attachments is the multi-photo minimum, while 0005_subscriptions adds tables used by current account/limit queries. Do not stop at the attachment revision when deploying the current server. See administrator and subscription operations.
uv sync --locked
uv run pytest -q
uv run ruff check app scripts tests migrations deploy/truenas/manage.py
uv run ruff format --check app scripts tests migrations deploy/truenas/manage.py
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.
.github/workflows/codeql.yml analyzes Python, JavaScript/TypeScript contract tooling, and GitHub Actions with security-extended. It runs on pull requests, pushes to main, weekly on Monday at 03:47 Asia/Seoul, and manual dispatch, without starting services or installing application dependencies.
.github/dependabot.yml checks uv (pyproject.toml/uv.lock), npm contract tools, GitHub Actions, Dockerfile images, and Docker Compose images weekly on Monday at 09:00 Asia/Seoul. uv/npm/Actions minor and patch version updates are grouped per ecosystem; major updates remain separate. No automatic merge is configured.
.github/workflows/dependency-review.yml fails pull requests introducing known vulnerabilities rated moderate or above across runtime, development, and unknown scopes. License allow/deny rules are not added by this workflow. GitHub's dependency graph does not directly parse uv.lock, so the workflow submits Python dependency snapshots for both the exact base and head commits before reviewing the PR. It also submits a current snapshot on main pushes and manual dispatch. npm and Actions use GitHub's native manifest analysis. See supported dependency graph ecosystems.
The API workflow uses pull_request_target so fork and Dependabot PR snapshots can be submitted with contents: write. The snapshot job downloads only uv.lock through GitHub's Contents API and runs the UvLock detector; it never checks out PR code, installs packages, or runs PR scripts. Keep this boundary when editing the workflow. The review job has only contents: read; no PAT or additional secret is needed. Snapshot submission errors or an empty detection fail the workflow. The detector downloads the upstream Component Detection binary at runtime, so network access is required.
Merge the files into the default branch, enable dependency graph, Dependabot alerts and security updates in Settings → Advanced Security (or Code security), and use CodeQL advanced setup, disabling any existing default setup. The first pull_request_target run is available after the workflow exists on the base branch. Confirm snapshots and alerts under Security and inspect the first Actions runs. To enforce merge blocking, require Dependency Review and CodeQL analysis checks in the main branch ruleset after they have run; configure code scanning merge protection for blocking by alert severity. Successful CodeQL execution alone does not mean there are no findings. These repository settings are separate from the committed files.
The contribution policy requires Conventional Commit PR titles and squash merge messages. Follow CONTRIBUTING and the bilingual release guide. API and client versions remain independent. Product versions do not automatically change API routes, wire formats or migrations.
Release Please reads version state and the first-run comparison ref from .release-please-manifest.json and release-please-config.json. It updates project/package/lock metadata, FastAPI version and generated OpenAPI info.version together; existing uv sync --locked and exporter/type checks remain required. The request/response schemas are unaffected by a version-only update. Review nonconventional commits manually in the first release notes; see the repository release guide for bootstrap history.
Release PR merging creates a draft GitHub Release and a stable tag using a repository-scoped GitHub App token. Existing tag CI must pass verify and compose-smoke, publish the GHCR image, and upload its immutable deployment.json before the draft is published. Release notes are preserved. Successful publication reruns validate and retain existing artifacts; incomplete published releases fail instead of being overwritten. A failed upload leaves a draft and can be retried. TrueNAS continues to consume published stable releases with descriptors.
The new Commit and release policy workflow runs dependency-free Python 3.12 title/version checks and publisher failure-path tests. App configuration, squash settings, tag protection and required checks need separate GitHub activation; automatic release-PR merging is initially disabled. Source files do not prove those settings or actual registry/TrueNAS operation. See the release guide for activation and recovery.
- 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 · 프로필 문서