Skip to content

Comments

Refactor to chained DI, migrate to uv, add vehicles router#2

Open
adamontherun wants to merge 7 commits intomainfrom
convert-to-chained-depends
Open

Refactor to chained DI, migrate to uv, add vehicles router#2
adamontherun wants to merge 7 commits intomainfrom
convert-to-chained-depends

Conversation

@adamontherun
Copy link
Contributor

Summary

  • Chained dependency injection: Router → Service → Database Client. Each layer depends only on the layer below via Depends(). Router tests override the service; service tests inject a mock DB client; DB client tests inject a mock session.
  • uv: Replaced requirements.txt with pyproject.toml and uv sync.
  • Testing: Lazy engine so unit tests run without DATABASE_URL. Integration tests use a real Postgres session with transaction rollback. load_dotenv() in main.py so uvicorn loads .env.
  • Vehicles: Mounted vehicles_router, fixed SwapiVehicleError and VehicleNotFoundError handlers, simplified vehicle schemas to match the character pattern (create needs only name).

adamontherun and others added 4 commits February 21, 2026 18:13
Co-authored-by: Cursor <cursoragent@cursor.com>
- database.py: lazy get_engine() so unit tests need no DATABASE_URL
- main.py: load_dotenv() at top so uvicorn loads .env
- test_create_character_invalid_data: override CharactersService to avoid DB chain
- tests/integration_tests/conftest.py: sync integration_client with transaction rollback
- Integration tests use integration_client fixture
- README: DI chain, testing strategy, uv setup (no async references)

Co-authored-by: Cursor <cursoragent@cursor.com>
- main.py: include vehicles_router, wire SwapiVehicleError and vehicle_not_found_error_handler
- StarWarsVehicleCreate: require only name (matches character pattern, service fetches from SWAPI)
- StarWarsVehicleRead: optional fields, remove pilots (never populated)
- SwapiVehicle: optional fields for SWAPI response parsing

Co-authored-by: Cursor <cursoragent@cursor.com>
adamontherun and others added 3 commits February 21, 2026 21:08
…omain, utils

The DI chain rewrite dropped context about Pydantic schemas, SQLAlchemy models,
networking clients, domain logic, and utils. Added it back as a compact section
between project layout and naming.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant