Hábito. organises its HTTP surface into three Flask Blueprints, each registered insideDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/BrandonCVale/SISTEMA-HABITOS/llms.txt
Use this file to discover all available pages before exploring further.
create_app() in app/__init__.py. The auth_bp blueprint (prefix /auth) handles registration, login, and logout. The pag_principal_bp blueprint (prefix /pagina_principal) owns the main dashboard. The habito_bp blueprint (prefix /habitos) manages the full habit CRUD lifecycle. There is also a bare root route (/) that immediately redirects every visitor to the login page.
Root Route
| Path | Method | Auth Required | Behaviour |
|---|---|---|---|
/ | GET | No | Redirects to /auth/inicio_sesion |
Auth Blueprint
Blueprint name:auth_bp · URL prefix: /auth · Source: app/routes/auth.py
The auth blueprint is registered as 'auth', so all internal url_for() calls use the auth. namespace (e.g. url_for('auth.inicio_sesion')).
Endpoints
- GET /auth/registro
- POST /auth/registro
- GET /auth/inicio_sesion
- POST /auth/inicio_sesion
- GET /auth/cerrar_sesion
Method: GET
Auth required: No
Description: Renders the
Auth required: No
Description: Renders the
registro.html registration form. If the user already has an active session (current_user.is_authenticated), they are redirected to the dashboard instead with a "success" flash.Redirect on already-authenticated: → pag_principal.inicioAuth route summary table
| Route | Methods | Login Required | Success Redirect |
|---|---|---|---|
/auth/registro | GET, POST | No | auth.registro (POST) |
/auth/inicio_sesion | GET, POST | No | pag_principal.inicio (POST) |
/auth/cerrar_sesion | GET | Yes | auth.inicio_sesion |
Dashboard Blueprint
Blueprint name:pag_principal_bp · URL prefix: /pagina_principal · Source: app/routes/pagina_principal.py
The dashboard is a single, read-only view. It aggregates data from several repository calls and passes everything to the pagina_principal.html template.
Endpoints
- GET /pagina_principal/inicio
Method: GET
Auth required: Yes (
Description: Builds and renders the main dashboard. Performs the following work before rendering:
Auth required: Yes (
@login_required)Description: Builds and renders the main dashboard. Performs the following work before rendering:
- Fetches all active habits for
current_userviaHabitoRepository.obtener_habitos_por_usuario(current_user.id). - Determines today’s day-letter (
L–D) and filters habits that are bothactivo=Trueand scheduled for today. - Annotates each habit with a transient
completado_hoyattribute (bool) by scanninghabito.registros. - Queries
HabitoRepository.obtener_dias_activos_mes()to produce the set of calendar day-numbers used by the heat-map. - Computes three KPIs: habits completed today, current best streak, all-time best streak.
| Variable | Type | Description |
|---|---|---|
usuario | Usuario | The logged-in user object |
habitos | list[Habito] | Today’s active habits (with completado_hoy) |
mes_actual | str | Spanish month name (e.g. "Julio") |
num_dias | int | Number of days in current month |
dia_semana_inicio | int | Weekday of the 1st of the month (0=Mon) |
dias_completados | set[int] | Day numbers with ≥1 completion this month |
habitos_completados_hoy | int | Count of today’s completed habits |
racha_actual | int | Highest current streak across all habits |
mejor_racha | int | Highest all-time streak across all habits |
Habits Blueprint
Blueprint name:habito_bp · URL prefix: /habitos · Source: app/routes/habito.py
All routes in this blueprint require an authenticated session. Routes that operate on a specific habit by id additionally check that habito.usuario_id == current_user.id before proceeding — see Ownership Security below.
Endpoints
- GET /habitos/mis_habitos
- POST /habitos/crear
- GET /habitos/editar/<id>
- POST /habitos/editar/<id>
- POST /habitos/eliminar/<id>
- POST /habitos/completar/<id>
- GET /habitos/visualizar_progreso/<id>
Method: GET
Auth required: Yes
Description: Renders
Auth required: Yes
Description: Renders
habitos.html with the full list of the user’s habits. Accepts an optional ?estado= query parameter.estado value | Effect |
|---|---|
activos (default) | Only habits with activo=True |
inactivos | Only habits with activo=False |
todos | All habits regardless of status |
Habits route summary table
| Route | Methods | Login Required | Ownership Check |
|---|---|---|---|
/habitos/mis_habitos | GET | Yes | No |
/habitos/crear | POST | Yes | No |
/habitos/editar/<id> | GET, POST | Yes | Yes |
/habitos/eliminar/<id> | POST | Yes | Yes |
/habitos/completar/<id> | POST | Yes | Yes |
/habitos/visualizar_progreso/<id> | GET | Yes | Yes |
Ownership Security Checks
Any route that targets a specific habit by ID applies the following guard before doing any work:None returned by the repository) or belongs to a different user, the request is silently rejected with an error flash and a redirect — no habit data is leaked to the requester.
Flash Messages
Hábito. uses Flask’sflash() function throughout all three blueprints to communicate outcomes to the user. Flash messages are stored in the session for one request and rendered by the template on the next page load.
Two categories are used:
| Category | When used |
|---|---|
"success" | Operation completed successfully (login, registration, habit created, etc.) |
"error" | Validation failure, wrong credentials, ownership violation, or missing resource |
app/__init__.py: