Part 6: A Makefile for the project
The backend now runs with python main.py and the frontend runs with
npm run dev, each in its own folder 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. Before we connect the two sides,
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.
Create the Makefile
Ask the assistant:
Add a Makefile at the repo root with these targets:
- install (install backend and frontend dependencies)
- backend (run the backend only)
- frontend (run the frontend only)
- backend-tests
- frontend-tests
- test (run both test suites)
The first version wraps the commands we already run by hand:
.PHONY: install backend frontend backend-tests frontend-tests test
install:
cd backend && uv sync
cd frontend && npm install
backend:
cd backend && uv run python main.py
frontend:
cd frontend && npm run dev
backend-tests:
cd backend && uv run pytest
frontend-tests:
cd frontend && npm test
test: backend-tests frontend-tests
Now the project has a handful of short commands:
make install # set up both sides
make backend # run the backend
make frontend # run the frontend
make test # run both test suites
We keep backend-tests and frontend-tests as separate targets so we can run
one suite on its own. The CI/CD pipeline relies on that later in
Part 13: CI/CD with GitHub Actions to run them as separate jobs.
Commit the Makefile:
git add .
git commit -m "Add Makefile with test and run targets"
With the commands collected, we connect the frontend to the backend and run them together in Part 7: Connect frontend and backend.