2.5 KiB
2.5 KiB
Repository Guidelines
Project Structure & Module Organization
backend/: FastAPI service.- App code:
backend/app/(routesbackend/app/api/, modelsbackend/app/models/, schemasbackend/app/schemas/, workersbackend/app/workers/). - DB migrations:
backend/migrations/(generated versions inbackend/migrations/versions/). - Tests:
backend/tests/.
- App code:
frontend/: Next.js app.- Routes:
frontend/src/app/; shared UI:frontend/src/components/; utilities:frontend/src/lib/. - Generated API client:
frontend/src/api/generated/(do not edit by hand). - Tests: colocated
*.test.ts(x)(example:frontend/src/lib/backoff.test.ts).
- Routes:
templates/: shared templates packaged into the backend image (used by gateway integrations).docs/: protocol/architecture notes (seedocs/openclaw_gateway_ws.md).
Build, Test, and Development Commands
From repo root:
make setup: install/sync backend + frontend dependencies.make check: CI-equivalent suite (lint, typecheck, tests/coverage, frontend build).docker compose -f compose.yml --env-file .env up -d --build: run full stack (Postgres + Redis included).
Fast local dev:
docker compose -f compose.yml --env-file .env up -d db redis- Backend:
cd backend && uv sync --extra dev && uv run uvicorn app.main:app --reload --port 8000 - Frontend:
cd frontend && npm install && npm run dev - API client:
make api-gen(backend must be running on127.0.0.1:8000).
Coding Style & Naming Conventions
- Python: Black + isort (line length 100), flake8 (
backend/.flake8), strict mypy (backend/pyproject.toml). Usesnake_case. - TypeScript/React: ESLint (Next.js) + Prettier (
make frontend-format). ComponentsPascalCase, variablescamelCase. Prefix intentionally-unused destructured props with_(seefrontend/eslint.config.mjs). - Optional:
pre-commit installto run format/lint hooks locally.
Testing Guidelines
- Backend: pytest (
backend/tests/, filestest_*.py). Runmake backend-testormake backend-coverage(writesbackend/coverage.xml). - Frontend: vitest + testing-library. Run
make frontend-test(writesfrontend/coverage/).
Commit & Pull Request Guidelines
- Commits: Conventional Commits (e.g.,
feat: ...,fix: ...,docs: ...,chore: ...,refactor: ...; optional scope likefeat(chat): ...). - PRs: include what/why, how to test (ideally
make check), linked issue (if any), and screenshots for UI changes.
Security & Configuration Tips
- Never commit secrets. Use
.env.exampleas the template and keep real values in.env.