|
| 1 | +## Project Domain |
| 2 | + |
| 3 | +This is a REST API for browsing and managing a collection of cars. |
| 4 | +Each car is a complete record with a unique, server-assigned `id` |
| 5 | +and the fields `make`, `model`, `year`, `horsepower`, `engine_cc`, |
| 6 | +and `transmission`. |
| 7 | + |
| 8 | +The `engine_cc` field can be `0` for fully electric cars. Every |
| 9 | +car you return or store must include all fields. |
| 10 | + |
| 11 | +## Project Setup and Management |
| 12 | + |
| 13 | +- Python version: 3.14. Don't use newer syntax. |
| 14 | +- Dependency management: `uv` and `pyproject.toml`. Never use `pip` |
| 15 | + or a `requirements.txt` file. |
| 16 | +- Add a dependency with `uv add <package>`. Never use `uv pip` |
| 17 | + for dependencies. |
| 18 | +- Run the app with `uv run fastapi dev main.py`. |
| 19 | +- Branch from `main` as `feature/<name>` and use Conventional Commits. |
| 20 | +- Stage changes for review. Don't commit to `main` or push without |
| 21 | + being asked. |
| 22 | + |
| 23 | +## Coding Conventions |
| 24 | + |
| 25 | +- Type-hint public functions and methods, including their return types. |
| 26 | +- Use `pathlib` for path management. Don't use `os.path`. |
| 27 | +- Prefer f-strings over `str.format()` or `%` formatting. |
| 28 | +- Follow EAFP: handle exceptions rather than checking conditions up front. |
| 29 | +- Write Google-style docstrings for every public function and method. |
| 30 | +- Validate request bodies with Pydantic models. |
| 31 | +- Embrace idiomatic Python like comprehensions, generators, and decorators. |
| 32 | + |
| 33 | +## Project Structure |
| 34 | + |
| 35 | +- The project is flat: `main.py` holds the app and `cars.json` holds |
| 36 | + the data. |
| 37 | +- The `main.py` file is the only module to edit when adding features. |
| 38 | +- Put tests in `tests/test_main.py`. |
| 39 | +- Don't create new packages or new files without being asked. |
| 40 | + |
| 41 | +## Quality Gates |
| 42 | + |
| 43 | +A task is done only when all of these pass: |
| 44 | + |
| 45 | +- `uv run ruff format` leaves the code unchanged. |
| 46 | +- `uv run ruff check` reports no errors. |
| 47 | +- `uv run mypy main.py` reports no errors. |
| 48 | +- `uv run pytest` passes, with a test added for every new endpoint. |
| 49 | + |
| 50 | +## Constraints |
| 51 | + |
| 52 | +- Ask before adding any external dependency. |
| 53 | +- Preserve the signature and response shape of existing endpoints. |
| 54 | +- Don't use blocking I/O inside `async` functions. |
| 55 | +- Keep existing tests intact, and fix the code to make them pass. |
| 56 | +- Declare a task done only after the gates pass and docstrings are |
| 57 | + updated. |
| 58 | + |
| 59 | +## Ignore |
| 60 | + |
| 61 | +Treat everything in `.gitignore` as off-limits to read or edit. On top of |
| 62 | +that, never open: |
| 63 | + |
| 64 | +- Secrets and `.env` files |
| 65 | +- Large data files unrelated to the current task |
| 66 | +- Vendored or generated code |
0 commit comments