How 20225scorpion/backend_hotel works
Hotel Asturias API is a FastAPI backend for hotel operations and staff accounts. Users register or log in to obtain a token; protected requests resolve that token to a user before reaching operational endpoints. The main domain stages are room and guest management, stays, income and expenses, reporting, and audit/history. SQLAlchemy models persist the domain records. The source index identifies the router dependencies, but several router implementations were not excerpted, so their detailed calls are not asserted here.
Main entry points: main.py FastAPI app · database.py SQLAlchemy setup · hospedajes.py Stays API · habitaciones.py Rooms API
Components 23
API entry
- FastAPI app
main.py
Identity and access
- Token and passwords
auth/auth_handler.py - Bearer verification
auth/auth_bearer.py - Role checks
auth/role_checker.py - Request dependencies
deps.py
Hotel operations
- Rooms API
routers/habitaciones.py - Guests API
routers/huespedes.py - Stays API
routers/hospedajes.py - Income API
routers/ingresos.py - Expenses API
routers/gastos.py - Reports API
routers/reportes.py - Audit API
routers/auditoria.py
Persistence
- SQLAlchemy setup
database.py - User records
models/user_model.py - Room records
models/habitacion_model.py - Guest records
models/huesped_model.py - Stay records
models/hospedaje_model.py - Income records
models/ingreso_model.py - Expense records
models/gasto_model.py - Tax records
models/impuesto_model.py - Audit records
models/auditoria_model.py - Deletion records
models/registro_eliminado_model.py
Other components
- API client
Connections 42
- API client → FastAPI app: sends requests
main.py - FastAPI app → Rooms API: mounts routes
main.py - FastAPI app → Guests API: mounts routes
main.py - FastAPI app → Income API: mounts routes
main.py - FastAPI app → Expenses API: mounts routes
main.py - FastAPI app → Stays API: mounts routes
main.py - FastAPI app → Reports API: mounts routes
main.py - FastAPI app → Audit API: mounts routes
main.py - FastAPI app → Token and passwords: hashes and issues
main.py - FastAPI app → User records: queries and writes
main.py - FastAPI app → Audit records: records login
main.py - FastAPI app → Bearer verification: protects profile
main.py - FastAPI app → Role checks: checks privileged routes
main.py - Request dependencies → Bearer verification: verifies token
deps.py - Request dependencies → User records: resolves account
deps.py - Bearer verification → Token and passwords: uses signing settings
auth/auth_bearer.py - Role checks → Bearer verification: depends on verification
auth/role_checker.py - SQLAlchemy setup → User records: provides model base
models/user_model.py - SQLAlchemy setup → Room records: provides model base
models/habitacion_model.py - SQLAlchemy setup → Stay records: provides model base
models/hospedaje_model.py - SQLAlchemy setup → Income records: provides model base
models/ingreso_model.py - SQLAlchemy setup → Audit records: provides model base
models/auditoria_model.py - SQLAlchemy setup → Deletion records: provides model base
models/registro_eliminado_model.py - Rooms API → Request dependencies: uses request access
routers/habitaciones.py - Rooms API → Room records: queries and updates
routers/habitaciones.py - Rooms API → Audit records: records changes
routers/habitaciones.py - Rooms API → Deletion records: records removals
routers/habitaciones.py - Guests API → Request dependencies: uses request access
routers/huespedes.py - Guests API → Guest records: manages guests
routers/huespedes.py - Stays API → Request dependencies: uses request access
routers/hospedajes.py - Stays API → Stay records: manages stays
routers/hospedajes.py - Stays API → Room records: uses room records
routers/hospedajes.py - Stays API → Guest records: uses guest records
routers/hospedajes.py - Stays API → Income records: records stay income
routers/hospedajes.py - Income API → Income records: manages income
routers/ingresos.py - Expenses API → Expense records: manages expenses
routers/gastos.py - Reports API → Income records: reads income
routers/reportes.py - Reports API → Expense records: reads expenses
routers/reportes.py - Reports API → Stay records: reads stays
routers/reportes.py - Reports API → Room records: reads rooms
routers/reportes.py - Audit API → Audit records: reads audit history
routers/auditoria.py - Audit API → Deletion records: reads deletion history
routers/auditoria.py