The Hábito. dashboard is the first screen a user sees after logging in. It consolidates everything relevant to the current day: the habits scheduled for today, three at-a-glance KPI cards, and a monthly heat-map calendar that visualises which days during the current month had at least one completed habit. The dashboard is served from theDocumentation 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.
/pagina_principal/inicio route and requires an active session — unauthenticated visitors are redirected to the login page automatically.
Today’s Habits
Route:GET /pagina_principal/inicio
Not all habits are shown on the dashboard — only those that are active and scheduled for today’s day of the week. The route resolves which habits belong to today using Python’s date.weekday() method and a lookup dictionary that maps weekday integers to the single-letter codes stored in dias_semana:
completado_hoy attribute to each habit object by scanning its registros relationship for a record matching today’s date. The Jinja2 template uses this attribute to render the completion button in its correct checked or unchecked state.
Each habit card on the dashboard includes:
- The habit name and optional description
- A toggle button that posts to
POST /habitos/completar/<id>to mark or unmark completion
KPI Cards
Three summary metrics are computed server-side from the habits data and passed directly to the template as template variables.Hábitos completados hoy
habitos_completados_hoyA count of how many of today’s scheduled habits have already been marked complete. Computed as:Racha actual
racha_actualThe highest racha_actual value across all of the user’s habits (not just today’s). Represents the user’s best active consecutive-day streak right now:+ [0] guard ensures the expression returns 0 rather than raising a ValueError when the user has no habits yet.Mejor racha
mejor_rachaThe highest mejor_racha value ever recorded across all habits — the user’s all-time personal record:Monthly Heat-Map Calendar
The calendar section of the dashboard highlights every day in the current month on which the user completed at least one habit. It is built entirely in Python and rendered with Jinja2 — no JavaScript calendar library is required.Computing the calendar data
The route collects three pieces of information needed to render the grid:| Variable | Type | Purpose |
|---|---|---|
num_dias | int | Total days in the current month (28–31) |
dia_semana_inicio | int (0–6) | Weekday of the 1st — used to offset the first calendar cell |
dias_completados | set[int] | Day numbers (e.g. {3, 7, 14}) with at least one completion |
The repository query
HabitoRepository.obtener_dias_activos_mes performs a SQL JOIN between registro_habitos and habitos to scope the results to the current user, then extracts only the day numbers into a Python set for O(1) look-up in the template:
Rendering in Jinja2
The template receivesnum_dias, dia_semana_inicio, and dias_completados (the set). It uses dia_semana_inicio to insert the correct number of empty leading cells so the first day of the month falls on the right column, then iterates from 1 to num_dias. For each day it checks membership in dias_completados to apply a highlight CSS class:
mes_actual: