Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Checks for backend/, which is rendered from python-copier-template
# (see docs/backend-sync.md). Kept as a thin repo-owned workflow because the
# rendered workflows assume the project sits at the repository root.
# Checks for backend/. Kept as a repo-owned workflow because the ones rendered
# from python-copier-template assume the project sits at the repository root.
name: Backend

on:
Expand Down
35 changes: 10 additions & 25 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
# CLAUDE.md

Fullstack template: React frontend (`frontend/`) + FastAPI backend (`backend/`).

## Ownership model — IMPORTANT

- `backend/` is a **rendered mirror** of
[python-copier-template](https://github.com/Komorebi-AI/python-copier-template)
(answers in `backend/.copier-answers.yml`). Do NOT edit files under
`backend/` in this repo: a sync job re-renders the template and replaces the
whole directory, wiping local changes. Backend changes belong in
python-copier-template. Exceptions applied by the sync itself: rendered
`.github/` is dropped, and `[tool.setuptools_scm] root = ".."` is set in
`backend/pyproject.toml`. Files marked `TEMPORARY` carry patches for known
upstream bugs. See `docs/backend-sync.md`.
- `frontend/` and everything at the repo root are owned by this repo and
edited normally.
React frontend (`frontend/`) + FastAPI backend (`backend/`).

## Commands

- Frontend (`cd frontend`): npm. `npm run dev` (port 5173), `npm test`,
- Frontend (`cd frontend`): npm. `npm run dev` (5173), `npm test`,
`npm run lint`, `npm run build`.
- Backend (`cd backend`): uv, never pip. `uv run python app/api.py` (port
7000), `uv run pytest`, `uv run ruff check .`, `uv run ty check app tests`.
- Full stack: `docker compose up --build` (port 8080). Root `Makefile` has
delegating targets.
- Backend (`cd backend`): uv, never pip. `uv run python app/api.py` (7000),
`uv run pytest`, `uv run ruff check .`, `uv run ty check app tests`.
- Both: root `Makefile` delegates (`make test`, `make lint`, `make up`).

## API contract
## Conventions

The frontend example calls `GET /api/` (version) and `POST /api/predict`;
both proxies (Vite dev, nginx) strip the `/api` prefix before the backend.
If a template sync changes `backend/app/api.py`, update
`frontend/src/api/backend.ts` and its tests to match.
- The frontend calls `/api/*`; both proxies (Vite dev, nginx) strip the prefix
before the backend. Keep endpoint wrappers in `frontend/src/api/`, typed and
matching `backend/app/api.py`.
- Keep `GET /health`: the compose healthcheck and CI depend on it.
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

Fullstack template at Komorebi AI: a **React frontend** (`frontend/`) paired with a
**FastAPI backend** (`backend/`). Use it as the starting point for technical tests,
experiments and app frontends — delete `backend/` if you only need the frontend.
experiments and apps.

Need only one half? Delete `frontend/` or `backend/` — or start from
[python-template](https://github.com/Komorebi-AI/python-template) for a backend-only
project.

## Structure

```
frontend/ React + TypeScript + Vite + MUI + TanStack Query → frontend/README.md
backend/ FastAPI example, rendered from python-copier-template (do not edit here!)
compose.yaml, Makefile, .github/ → repo-owned glue
backend/ FastAPI + uv, ruff, ty, pytest → backend/README.md
compose.yaml, Makefile, .github/ full-stack glue
```

**Ownership model**: `backend/` is a rendered mirror of
[python-copier-template](https://github.com/Komorebi-AI/python-copier-template) and is
replaced wholesale by an automated sync — backend changes belong in that template, not
here. See [docs/backend-sync.md](docs/backend-sync.md). Everything else is owned and
edited in this repo.

## Quickstart

Requirements: [Node 24](https://nodejs.org/) (see `frontend/.nvmrc`) and
Expand Down Expand Up @@ -53,10 +51,10 @@ make test # frontend Vitest + backend pytest
make lint # ESLint/Prettier + ruff/ty
```

CI runs three path-filtered workflows: **Frontend** (lint, format, test, build),
**Backend** (ruff, ty, pytest) and **Contract** — the latter boots the real backend and
exercises the endpoints the frontend uses, so a backend sync that breaks the API
contract fails visibly.
CI runs path-filtered workflows: **Frontend** (lint, format, test, build), **Backend**
(ruff, ty, pytest), **Contract** — boots the real backend and exercises the endpoints
the frontend calls, so frontend/backend drift fails visibly — and **Docker** (builds
both images and checks the same contract through nginx).

## API contract

Expand All @@ -76,9 +74,13 @@ endpoints, since the compose healthcheck and CI smoke tests rely on it.
## Starting a project from this template

1. Use GitHub's **"Use this template"** (or clone and re-init git).
2. Rename things: `frontend/package.json` name, `backend` answers if you re-render.
2. Rename things: `frontend/package.json` name, `backend/Makefile` image name,
`backend/pyproject.toml` name and description.
3. Replace the example page and endpoints with your app. Keep the patterns:
typed API wrappers, useQuery/useMutation, the `/api` prefix convention.
4. The backend keeps its link to python-copier-template via
`backend/.copier-answers.yml` — run `copier update` inside `backend/` to pull
future template improvements into your (by then customized) backend.
typed API wrappers, useQuery/useMutation, the `/api` prefix convention, and the
`/health` endpoint the compose healthcheck and CI rely on.

---

Maintaining this template itself: `backend/` is regenerated automatically, so changes
under it are overwritten — make them in our Python template instead.
12 changes: 0 additions & 12 deletions backend/.copier-answers.yml

This file was deleted.

172 changes: 0 additions & 172 deletions docs/backend-sync.md

This file was deleted.