Part 6: A Makefile for the project
In Part 5: Connect frontend and backend we ran the backend and frontend by hand. Each one ran in its own terminal with its own command. We install dependencies and run the tests the same way, one folder at a time.
That's a lot of commands to remember and retype. We collect them into a
Makefile at the repo root, so one short command runs each. We keep extending
this file in every part that follows.
The commands so far
By hand, running and testing the project looks like this:
- install:
cd backend && uv syncandcd frontend && npm install - backend:
cd backend && uv run uvicorn app.main:app --reload --port 8000 - frontend:
cd frontend && npm run dev - tests:
cd backend && uv run pytestandcd frontend && npm test
Create the Makefile
Ask the assistant:
Add a Makefile at the repo root with three targets: install (install backend and
frontend dependencies), dev (run the backend and frontend together), and test
(run both test suites). We'll add more targets in later steps.
The first version wraps exactly those commands:
.PHONY: install dev test
install:
cd backend && uv sync
cd frontend && npm install
dev:
@trap 'kill 0' EXIT; \
(cd backend && uv run uvicorn app.main:app --reload --port 8000) & \
(cd frontend && npm run dev) & \
wait
test:
cd backend && uv run pytest
cd frontend && npm test
The dev target runs both servers together, which a single command couldn't do
before. The trap 'kill 0' EXIT line stops both when you press Ctrl-C, and
wait holds the target open while they run.
From now on the project has three short commands:
make install # set up both sides
make dev # run the backend and frontend together
make test # run both test suites
We give the app a real database next in Part 7: Real persistence with SQLite, and we add a Makefile target for its tests there.