Módulo Horario is a distributed system made up of four independent FastAPI microservices. Each service owns its data store, exposes its own REST API, and can be deployed and scaled separately. The React frontend talks directly to whichever service owns the data it needs. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Luisanchez0/modulo_Horario/llms.txt
Use this file to discover all available pages before exploring further.
horario-service additionally calls the other three services at runtime to validate references before writing schedule entries.
Architecture overview
The four services
usuarios-service
Authentication, teacher management, and rate-limited login on port 8001.
materias-service
Subject catalog with async I/O via asyncpg on port 8002.
aulas-service
Classroom inventory and capacity management on port 8003.
horario-service
Schedule generation, period management, and cross-service validation on port 8004.
usuarios-service (port 8001)
usuarios-service is the authentication and teacher management service. It issues JWT tokens (HS256) signed with JWT_SECRET and enforces role-based access with ADMIN and DOCENTE roles. Login endpoints are protected by request rate limiting via slowapi, which returns HTTP 429 when a caller exceeds the threshold.
Teachers are stored in MySQL. The service exposes both public endpoints (login, register) and internal endpoints (teacher lookup) under /internal/docentes, which require the X-Internal-Key header matching INTERNAL_API_KEY.
Key environment variables (from docker-compose.yml):
materias-service (port 8002)
materias-service maintains the subject catalog. It is built with async FastAPI and uses asyncpg for non-blocking PostgreSQL access — the DATABASE_URL uses the postgresql+asyncpg:// scheme. The service verifies the JWT token for write operations by calling usuarios-service at the URL specified by USUARIOS_SERVICE_URL.
Key environment variables:
aulas-service (port 8003)
aulas-service stores classroom records (name, capacity, location) in MySQL. Like materias-service, it delegates auth token verification to usuarios-service.
Key environment variables:
horario-service (port 8004)
horario-service is the most complex service. It owns the schedule and period data in PostgreSQL, and it orchestrates data from the other three services at request time using CatalogServicesClient. Before persisting a schedule entry, it validates that the referenced teacher, subject, and classroom each exist in their respective owning services.
The client calls internal usuarios-service endpoints with the X-Internal-Key header. Calls to materias-service and aulas-service use their public APIs.
Database layout
Two database engines are shared across the four services. Each service connects to its own logical database.| Engine | Services | Logical databases |
|---|---|---|
| MySQL 8 | usuarios-service, aulas-service | docentes_db, aulas_db |
| PostgreSQL 16 | materias-service, horario-service | materias_db, horarios_db |
3307 and PostgreSQL on 5433 to avoid conflicts with any locally installed database servers.
Inter-service communication
horario-service is the only service that initiates calls to other services. All other inter-service communication flows from the frontend directly to each service’s REST API.
At runtime, horario-service uses CatalogServicesClient to:
- Look up and validate teacher IDs against
usuarios-service(/internal/docentes) - Look up and validate subject IDs against
materias-service(/api/v1/materias) - Look up and validate classroom IDs against
aulas-service(/aulas) - Resolve human-readable labels (name, email, subject code, classroom capacity) for schedule display
horario-service to usuarios-service carry an X-Internal-Key: <INTERNAL_API_KEY> header. Calls time out after UPSTREAM_TIMEOUT_SECONDS (default: 5 seconds), and any upstream error raises an UpstreamServiceError.
CORS configuration
All four services share the same CORS policy, configured through theCORS_ALLOW_ORIGINS environment variable. The default value allows requests from the frontend and from each service to the others:
docker-compose.yml and defaults to the same list in each service’s Python startup code when the variable is absent.