|
| 1 | +## Quick Start |
| 2 | + |
| 3 | +```bash |
| 4 | +docker compose up --build # Start all services (API :8000, Web :5173, Postgres :5432) |
| 5 | +make lint # Ruff check + format (API), ESLint (Web) |
| 6 | +make test # pytest (API), vitest (Web) |
| 7 | +make migrate # Alembic upgrade head |
| 8 | +``` |
| 9 | + |
| 10 | +## Architecture |
| 11 | + |
| 12 | +Monorepo with two apps and shared infra: |
| 13 | + |
| 14 | +``` |
| 15 | +apps/api/ — FastAPI backend (Python 3.12, uv) |
| 16 | + src/helprs/ |
| 17 | + core/ — config, database, dependencies, middleware, security |
| 18 | + modules/ — domain modules: identity, installation, webhook, billing, comprehension |
| 19 | + admin/ — SQLAdmin panel |
| 20 | + tests/ — mirrors modules/ structure |
| 21 | + alembic/ — DB migrations |
| 22 | +apps/web/ — React frontend (Vite, TypeScript) |
| 23 | + src/features/ — feature modules |
| 24 | + src/shared/ — shared components/utils |
| 25 | +infra/ |
| 26 | + docker/ — Dockerfiles (api, web) |
| 27 | + coolify/ — production docker-compose |
| 28 | +``` |
| 29 | + |
| 30 | +## Key Patterns |
| 31 | + |
| 32 | +- **App factory**: `helprs.main:create_app()` — lifespan manages DB engine |
| 33 | +- **Module structure**: each module has `router.py`, `service.py`, `models.py`, `schemas.py` |
| 34 | +- **API prefix**: all routes under `/api/v1` |
| 35 | +- **Admin panel**: SQLAdmin at `/admin`, configured in `admin/views.py` |
| 36 | + |
| 37 | +## Code Style |
| 38 | + |
| 39 | +- Python: ruff with `line-length = 120`, target Python 3.12 |
| 40 | +- Lint rules: E, F, I, N, UP, B, A, SIM, TCH |
| 41 | +- `asyncio_mode = "auto"` in pytest — no need for `@pytest.mark.asyncio` |
| 42 | + |
| 43 | +## Testing |
| 44 | + |
| 45 | +```bash |
| 46 | +cd apps/api && uv run pytest # All API tests |
| 47 | +cd apps/api && uv run pytest tests/modules/identity/ # Single module |
| 48 | +cd apps/web && npx vitest run # All frontend tests |
| 49 | +``` |
| 50 | + |
| 51 | +- Tests use `AsyncClient` with `ASGITransport` (no real server) |
| 52 | +- `conftest.py` sets env vars (DATABASE_URL, SECRET_KEY, etc.) **before** any app imports — order matters |
| 53 | + |
| 54 | +## Environment |
| 55 | + |
| 56 | +Required `.env` at repo root (see docker-compose.yml): |
| 57 | +- `DATABASE_URL` — Postgres connection string |
| 58 | +- `SECRET_KEY` — app secret |
| 59 | +- `GITHUB_APP_ID`, `GITHUB_WEBHOOK_SECRET` — GitHub App config |
| 60 | +- `FERNET_KEY` — encryption key for BYOK secrets |
| 61 | + |
| 62 | +## Gotchas |
| 63 | + |
| 64 | +- Always run `make lint` before pushing — ruff + eslint must pass |
| 65 | +- DB migrations: `make migrate` inside Docker, or `cd apps/api && uv run alembic upgrade head` locally |
| 66 | +- Test conftest **must** set env vars before importing from `helprs.*` |
0 commit comments