Polyglot monorepo starter: FastAPI + Next.js + Rust, with JWT auth, audit logging, async SQLAlchemy, Celery workers, Docker Compose, Prometheus, and Grafana dashboards. Rust can run as a standalone service or be compiled into Python extensions (PyO3) and WASM modules (wasm-bindgen) for direct import.
- Backend (FastAPI): Auth & audit routes, async SQLAlchemy + Alembic, Redis-backed rate limiting, Prometheus metrics, structured logging, Celery worker/beat scaffolding.
- Frontend (Next.js + TypeScript): Auth flows (login/register/profile), protected dashboard shell, typed API client, Tailwind styles.
- Rust: Binary service scaffold (
apps/rust-svc), PyO3 extension stub (packages/py-core), wasm-bindgen stub (packages/wasm-core), shared TS types (packages/ts-shared). - Agent scaffold: Stub LLM provider with
/api/v1/agents/runendpoint and frontend demo page to submit prompts. - Ops: Docker Compose for Postgres, Redis, backend, frontend, Prometheus, Grafana; health/readiness endpoints; Makefile helpers; Moon task runner for cross-language cached builds.
.
├── apps/
│ ├── api/ # FastAPI service (Python/uv)
│ ├── web/ # Next.js app (TypeScript/pnpm)
│ └── rust-svc/ # Rust binary service
├── packages/
│ ├── py-core/ # PyO3 crate → native .so for apps/api
│ ├── wasm-core/ # wasm-bindgen crate → WASM for apps/web
│ └── ts-shared/ # Shared TypeScript types
├── nginx/
├── prometheus/
├── grafana/
├── Cargo.toml # Cargo workspace root
├── pyproject.toml # uv workspace root
├── pnpm-workspace.yaml
├── docker-compose.yml
└── Makefile
Install these once on your machine before anything else:
| Tool | Version | Install |
|---|---|---|
| Rust + cargo | stable | curl https://sh.rustup.rs -sSf | sh |
| Python | ≥ 3.12 | python.org or brew install python |
| uv | latest | curl -LsSf https://astral.sh/uv/install.sh | sh |
| Node.js | ≥ 22 | brew install node or nodejs.org |
| pnpm | ≥ 9 | npm install -g pnpm or corepack enable && corepack prepare pnpm@latest --activate |
| Moon | latest | curl -fsSL https://moonrepo.dev/install/moon.sh | bash |
| Docker Desktop | latest | docker.com — needed for the full-stack path |
Optional (only needed when you start using the Rust extension stubs):
pip install maturin # PyO3 → Python .so (packages/py-core)
cargo install wasm-pack # Rust → WASM (packages/wasm-core)Verify your environment:
cargo --version && python3 --version && uv --version
node --version && pnpm --version && moon --versionReplace placeholders across the repo:
# macOS / Linux
grep -rl '{{PROJECT_NAME}}' . | xargs sed -i '' 's/{{PROJECT_NAME}}/My App/g'
grep -rl '{{PROJECT_NAME_SLUG}}' . | xargs sed -i '' 's/{{PROJECT_NAME_SLUG}}/my-app/g'
grep -rl 'project-name-slug' . | xargs sed -i '' 's/project-name-slug/my-app/g'cp apps/api/.env.example apps/api/.env
cp apps/web/.env.example apps/web/.envMinimum values to set in apps/api/.env:
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/myapp
JWT_SECRET_KEY=<generate below>
REDIS_URL=redis://localhost:6379/0Generate a JWT secret:
python3 -c "import secrets; print(secrets.token_urlsafe(32))"Set in apps/web/.env (or .env.local for local-only override):
NEXT_PUBLIC_API_URL=http://localhost:8000make install
# Runs: uv sync (Python) + pnpm install (Node) + cargo fetch (Rust)Verify the build graph works:
moon run :build
# rust-svc compiles; api wheel builds; py-core/wasm-core/web skip gracefully
# until maturin/wasm-pack/pnpm-install are completeYou still need Postgres and Redis running. The quickest way is Docker for just those two:
docker compose up -d postgres redisThen run migrations and start the servers:
# 1. Apply database migrations
cd apps/api && uv run alembic upgrade head && cd ../..
# 2. (Optional) Load fixture data
make seed # creates admin@example.com / ChangeMe123!
# 3. Start API (port 8000) + web (port 3000) in parallel
make devOpen:
- Web app → http://localhost:3000
- API docs → http://localhost:8000/api/docs
- API health → http://localhost:8000/api/v1/health
Builds and starts every service (Postgres, Redis, API, Celery, Web, nginx, Prometheus, Grafana):
docker compose up -d --buildWait ~30 s for migrations and health checks, then:
# (Optional) Seed fixture data inside the running container
make seedOpen:
- Web app → https://localhost (nginx, self-signed cert — accept the browser warning)
- API docs → http://localhost:8000/api/docs
- Prometheus → http://localhost:9091
- Grafana → http://localhost:3001 (admin / admin)
- pgAdmin → http://localhost:5050
Runs API and web with source mounted for live reload, nginx for TLS:
# First time only — installs deps into named Docker volumes
make docker-dev-prepare
# Start api + web + nginx with hot reload
make docker-dev-upMoon manages build ordering across languages automatically:
moon run :build # builds everything in dependency order (cached)
moon run :test # tests everything
moon run web:build # builds web after wasm-core + ts-shared
moon run api:build # builds api after py-coreBuild graph:
api:build ← py-core:build (Rust → Python .so via maturin)
web:build ← wasm-core:build (Rust → WASM via wasm-pack)
web:build ← ts-shared:build (TypeScript types)
- Lint/format:
make lintandmake format(runs ruff/black/isort for Python, eslint/prettier for TypeScript). - Type checks:
make api-typecheck(mypy). - Git hooks:
make pre-commit-install, then run on demand withmake pre-commit. - Sample data:
make seedloads fixture users (admin@example.com/ChangeMe123!) and basic audit events.
Canonical examples: apps/api/.env.example and apps/web/.env.example
| Variable | Where | Notes |
|---|---|---|
DATABASE_URL |
api | Postgres connection string |
JWT_SECRET_KEY |
api | Generate with secrets.token_urlsafe(32) |
REDIS_URL |
api | For Celery + rate limiting |
NEXT_PUBLIC_API_URL |
web | http://localhost:8000 (local), https://localhost (Docker) |
LLM_PROVIDER / LLM_MODEL / LLM_API_KEY |
api | Optional — for the agent scaffold |
- Backend workers: Single Uvicorn process by default. For horizontal scale, run multiple replicas behind nginx and set
UVICORN_WORKERS. Keep Alembic migrations as a one-shot job. - Celery: Scale
celery-workerreplicas independently.celery-beatmust stay singleton. - Sessions/state: Stateless JWT auth — safe to scale horizontally. Redis handles rate limiting.
- Redis persistence: Disabled by default. Enable AOF/RDB or use a managed Redis for durable state.
make api-test # pytest
make web-test # Playwright e2e
moon run :test # all projects (cached)- Add your domains: extend
apps/api/src/domainandapps/api/src/api/v1 - Expand
apps/web/srcpages/components for your use case - Add Rust logic to
packages/py-core(PyO3) orpackages/wasm-core(WASM) and import it - Wire CI/CD:
moon run :build :testas a single cached pipeline step