How apinto25/claude-code-automatizacion works
Purpose and Runtime
A compact CRUD API for scheduled appointments, designed for extension toward notifications. It runs as a Python ASGI service with FastAPI, using SQLAlchemy over a local SQLite database and Pydantic v2 at the HTTP boundary. Dependencies are managed with uv (pyproject.toml, uv.lock).
Primary launch target: uvicorn app.main:app --reload.
Application Composition
app/main.py creates the FastAPI application, initializes database tables, and attaches route modules. It is the composition root and startup boundary.
• app/main.py
• app/database.py
• app/routers/appointments.py
The exposed API is REST-oriented under /appointments/; FastAPI also supplies interactive OpenAPI/Swagger documentation at /docs.
Persistence Boundary
app/database.py owns SQLAlchemy infrastructure: SQLite engine configuration, declarative Base, session creation, and the request-scoped get_db dependency. Router handlers receive database sessions through dependency injection rather than constructing connections themselves.
• app/database.py
• app/models/appointment.py
• app/models/notification.py
SQLite is file-backed and requires no separate database service. SQLAlchemy models define persisted entities and table mappings.
Appointment Domain Model
Appointments are the primary domain aggregate. Their persisted representation includes title, optional description/location, scheduled date-time, and a constrained lifecycle status: pending, confirmed, or cancelled.
• app/models/appointment.py
• app/schemas/appointment.py
• app/crud/appointment.py
The model/schema split separates database concerns from API contracts, allowing request and response shapes to evolve independently of table internals.
HTTP Request Flow
For appointment endpoints, control flows:
1. FastAPI routes in app/routers/appointments.py match and parse requests.
2. Pydantic schemas in app/schemas/appointment.py validate create or partial-update payloads and serialize responses.
3. The router injects a SQLAlchemy session from app/database.py.
4. CRUD functions in app/crud/appointment.py perform reads, inserts, updates, commits, refreshes, or deletes against the model.
5. Routers translate missing resources and invalid operations into HTTP responses.
This keeps HTTP behavior, validation, and persistence operations in distinct layers.
Notification Extension Boundary
Notification-related model, schema, CRUD, and router modules already exist, forming the intended extension seam for appointment-triggered notification capabilities.
• app/models/notification.py
• app/schemas/notification.py
• app/crud/notification.py
• app/routers/notifications.py
No external messaging, email, queue, authentication provider, or cloud infrastructure is indicated. Any future notification delivery integration should remain behind this module boundary rather than coupling delivery concerns into appointment routes.
Key Architectural Constraints
The system is a single-process API backed by local SQLite; database lifecycle and schema creation are application-managed from the main entry point. API consumers interact only through FastAPI routes and Pydantic contracts; internal CRUD and SQLAlchemy models are not intended as external interfaces. Current automated coverage is focused on appointment model behavior (tests/test_appointment_model.py).
Main entry points: database.py Database infrastructure · appointments.py Appointment routes · notifications.py Notification routes · main.py Application root
Components 13
HTTP API
- OpenAPI / Swagger · FastAPI serves interactive documentation at /docs.
- Application root · Creates the app, initializes tables, and attaches routes.
app/main.py - Appointment routes · REST endpoints under /appointments/.
app/routers/appointments.py
Appointment domain
- Appointment contracts · Validates create and partial-update payloads and serializes responses.
app/schemas/appointment.py - Appointment CRUD · Performs appointment reads and mutations.
app/crud/appointment.py - Appointment entity · Stores scheduling details and pending, confirmed, or cancelled status.
app/models/appointment.py
Notification extension
Reserved boundary for future delivery capabilities.
- Notification routes
app/routers/notifications.py - Notification contracts
app/schemas/notification.py - Notification CRUD
app/crud/notification.py - Notification entity
app/models/notification.py
Persistence
- Database infrastructure · Owns the engine, Base, sessions, and request-scoped get_db dependency.
app/database.py - Local SQLite database
Other components
- API consumers
Connections 16
- API consumers → Appointment routes: REST requests
- API consumers → OpenAPI / Swagger: opens /docs
- Application root → Appointment routes: attaches
- Application root → Notification routes: attaches
- Application root → Database infrastructure: creates tables
- Appointment routes → Appointment contracts: validates / serializes
- Appointment routes → Database infrastructure: injects session
- Appointment routes → Appointment CRUD: invokes
- Appointment CRUD → Appointment entity: reads and mutates
- Appointment CRUD → Database infrastructure: uses session
- Notification routes → Notification contracts: uses
- Notification routes → Database infrastructure: injects session
- Notification routes → Notification CRUD: invokes
- Notification CRUD → Notification entity: reads and mutates
- Notification CRUD → Database infrastructure: uses session
- Database infrastructure → Local SQLite database: connects