How laakmus/shooting-log works
shooting-log is a REST API for recording firearms, training sessions, and ammunition use, then reporting fired-round totals and costs. A client reaches the registered FastAPI routes: weapon and training routes perform CRUD, while training-entry creation validates a weapon and uses domain logic to derive round counts. Statistics and weapon-detail routes call database queries for aggregates. Routers use Pydantic schemas and SQLAlchemy sessions; models define the persisted entities. README documents the capabilities, while the sampled source clarifies their wiring.
Main entry points: database.py Session and engine · weapons.py Weapon routes · training.py Training routes · main.py FastAPI app
Components 12
HTTP API
- FastAPI app
src/main.py - Weapon routes
src/routers/weapons.py - Training routes
src/routers/training.py - Statistics route
src/routers/stats.py - Request and response schemas
src/schemas.py
Domain Logic
- Round calculation
src/services.py
Persistence and Queries
- Aggregate queries
src/queries.py - Session and engine
src/database.py - Application settings
src/config.py - ORM entities
src/models.py
Other components
- API client
- PostgreSQL
Connections 20
- API client → FastAPI app: sends requests
- FastAPI app → Weapon routes: dispatches
- FastAPI app → Training routes: dispatches
- FastAPI app → Statistics route: dispatches
- Weapon routes → Request and response schemas: validates and shapes
- Training routes → Request and response schemas: validates and shapes
- Statistics route → Request and response schemas: shapes response
- Training routes → Round calculation: calculates rounds
- Weapon routes → Aggregate queries: counts rounds
- Statistics route → Aggregate queries: loads cost totals
- Weapon routes → Session and engine: uses session
- Training routes → Session and engine: uses session
- Statistics route → Session and engine: uses session
- Aggregate queries → Session and engine: executes queries
- Session and engine → Application settings: loads connection settings
- ORM entities → Session and engine: uses declarative base
- Weapon routes → ORM entities: reads and writes
- Training routes → ORM entities: reads and writes
- Aggregate queries → ORM entities: aggregates entities
- Session and engine → PostgreSQL: connects