2.6 KiB
2.6 KiB
Repository Guidelines
Project Structure & Module Organization
backend/: FastAPI service. App code lives inbackend/app/(routes inbackend/app/api/, models inbackend/app/models/, schemas inbackend/app/schemas/, workers inbackend/app/workers/). DB migrations are inbackend/alembic/(generated files inbackend/alembic/versions/).frontend/: Next.js app. Routes live infrontend/src/app/; shared UI infrontend/src/components/; utilities infrontend/src/lib/; generated API client infrontend/src/api/generated/(do not edit by hand).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 (includes Postgres + Redis).
Fast local dev loop:
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
Other useful targets: make backend-migrate (alembic upgrade), make api-gen (regenerate TS client; backend must be running on 127.0.0.1:8000).
Coding Style & Naming Conventions
- Python: Black + isort (line length 100), flake8 (
backend/.flake8), mypy is strict (backend/pyproject.toml). Prefersnake_casefor modules/functions. - TypeScript/React: ESLint (Next.js config) + Prettier (
make frontend-format). PreferPascalCasecomponents andcamelCasevars; prefix intentionally-unused destructured props with_(seefrontend/eslint.config.mjs). - Optional:
pre-commit installto run formatting/lint hooks on commit.
Testing Guidelines
- Backend: pytest in
backend/tests/(filestest_*.py); runmake backend-testormake backend-coverage(writesbackend/coverage.xml). - Frontend: vitest + testing-library; prefer
*.test.ts(x)near the code (example:frontend/src/lib/backoff.test.ts); runmake frontend-test(writesfrontend/coverage/).
Commit & Pull Request Guidelines
- Use Conventional Commits (seen in history):
feat: ...,fix: ...,docs: ...,chore: ...,refactor: ...with optional scope likefeat(chat): .... - PRs should include: what/why, how to test (ideally
make check), linked issue (if any), and screenshots for UI changes. Never commit secrets; use.env.examplefiles as templates.