# apinto25/claude-code-automatizacion architecture

> Architecture diagram of the GitHub repository apinto25/claude-code-automatizacion, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/apinto25/claude-code-automatizacion
- Repository: https://github.com/apinto25/claude-code-automatizacion

## Overview

#### 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: [`app/database.py`](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/database.py) (Database infrastructure), [`app/routers/appointments.py`](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/routers/appointments.py) (Appointment routes), [`app/routers/notifications.py`](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/routers/notifications.py) (Notification routes), [`app/main.py`](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/main.py) (Application root)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_docs["OpenAPI / Swagger<br/>API documentation"]
  node_main["Application root<br/>FastAPI composition<br/>[main.py]"]
  node_appointment_routes["Appointment routes<br/>FastAPI router<br/>[appointments.py]"]
end

subgraph group_appointment["Appointment domain"]
  node_appointment_schemas["Appointment contracts<br/>Pydantic schemas<br/>[appointment.py]"]
  node_appointment_crud["Appointment CRUD<br/>persistence operations<br/>[appointment.py]"]
  node_appointment_model["Appointment entity<br/>SQLAlchemy model<br/>[appointment.py]"]
end

subgraph group_notification["Notification extension"]
  node_notification_routes["Notification routes<br/>FastAPI router<br/>[notifications.py]"]
  node_notification_schemas["Notification contracts<br/>Pydantic schemas<br/>[notification.py]"]
  node_notification_crud["Notification CRUD<br/>persistence operations<br/>[notification.py]"]
  node_notification_model["Notification entity<br/>SQLAlchemy model<br/>[notification.py]"]
end

subgraph group_persistence["Persistence"]
  node_database["Database infrastructure<br/>SQLAlchemy session dependency<br/>[database.py]"]
  node_sqlite[("Local SQLite database<br/>file-backed database")]
end

node_client(("API consumers<br/>external client"))

node_client -->|"REST requests"| node_appointment_routes
node_client -->|"opens /docs"| node_docs
node_main -->|"attaches"| node_appointment_routes
node_main -->|"attaches"| node_notification_routes
node_main -->|"creates tables"| node_database
node_appointment_routes -->|"validates / serializes"| node_appointment_schemas
node_appointment_routes -->|"injects session"| node_database
node_appointment_routes -->|"invokes"| node_appointment_crud
node_appointment_crud -->|"reads and mutates"| node_appointment_model
node_appointment_crud -->|"uses session"| node_database
node_notification_routes -->|"uses"| node_notification_schemas
node_notification_routes -->|"injects session"| node_database
node_notification_routes -->|"invokes"| node_notification_crud
node_notification_crud -->|"reads and mutates"| node_notification_model
node_notification_crud -->|"uses session"| node_database
node_database -->|"connects"| node_sqlite

click node_main "https://github.com/apinto25/claude-code-automatizacion/blob/main/app/main.py"
click node_appointment_routes "https://github.com/apinto25/claude-code-automatizacion/blob/main/app/routers/appointments.py"
click node_notification_routes "https://github.com/apinto25/claude-code-automatizacion/blob/main/app/routers/notifications.py"
click node_appointment_schemas "https://github.com/apinto25/claude-code-automatizacion/blob/main/app/schemas/appointment.py"
click node_appointment_crud "https://github.com/apinto25/claude-code-automatizacion/blob/main/app/crud/appointment.py"
click node_appointment_model "https://github.com/apinto25/claude-code-automatizacion/blob/main/app/models/appointment.py"
click node_notification_schemas "https://github.com/apinto25/claude-code-automatizacion/blob/main/app/schemas/notification.py"
click node_notification_crud "https://github.com/apinto25/claude-code-automatizacion/blob/main/app/crud/notification.py"
click node_notification_model "https://github.com/apinto25/claude-code-automatizacion/blob/main/app/models/notification.py"
click node_database "https://github.com/apinto25/claude-code-automatizacion/blob/main/app/database.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_docs,node_main,node_appointment_routes toneBlue
class node_appointment_schemas,node_appointment_crud,node_appointment_model toneAmber
class node_notification_routes,node_notification_schemas,node_notification_crud,node_notification_model toneMint
class node_database,node_sqlite toneRose
class node_client toneNeutral
```

## Components

### HTTP API

- **OpenAPI / Swagger**: API documentation · FastAPI serves interactive documentation at /docs.
- [Application root](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/main.py): FastAPI composition · Creates the app, initializes tables, and attaches routes. · `app/main.py`
- [Appointment routes](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/routers/appointments.py): FastAPI router · REST endpoints under /appointments/. · `app/routers/appointments.py`

### Appointment domain

- [Appointment contracts](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/schemas/appointment.py): Pydantic schemas · Validates create and partial-update payloads and serializes responses. · `app/schemas/appointment.py`
- [Appointment CRUD](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/crud/appointment.py): persistence operations · Performs appointment reads and mutations. · `app/crud/appointment.py`
- [Appointment entity](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/models/appointment.py): SQLAlchemy model · Stores scheduling details and pending, confirmed, or cancelled status. · `app/models/appointment.py`

### Notification extension

Reserved boundary for future delivery capabilities.

- [Notification routes](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/routers/notifications.py): FastAPI router · `app/routers/notifications.py`
- [Notification contracts](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/schemas/notification.py): Pydantic schemas · `app/schemas/notification.py`
- [Notification CRUD](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/crud/notification.py): persistence operations · `app/crud/notification.py`
- [Notification entity](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/models/notification.py): SQLAlchemy model · `app/models/notification.py`

### Persistence

- [Database infrastructure](https://github.com/apinto25/claude-code-automatizacion/blob/main/app/database.py): SQLAlchemy session dependency · Owns the engine, Base, sessions, and request-scoped get_db dependency. · `app/database.py`
- **Local SQLite database**: file-backed database

### Other components

- **API consumers**: external client

## Connections

- 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
