How antonymittul/momentum works
Purpose and Runtime Topology
Momentum is a local-first AI productivity companion for daily tasks, habits (“non-negotiables”), goals, notes, consistency metrics, and AI-generated coaching/reports. It runs as a Next.js 15 frontend and a FastAPI backend, with SQLite persistence. Primary startup points are frontend/src/app/layout.tsx, frontend/src/app/page.tsx, and backend/main.py.
Frontend Application Shell and Navigation
The frontend uses the Next.js App Router to provide feature pages and global presentation/theme behavior. The dashboard is rooted at frontend/src/app/page.tsx; dedicated routes cover tasks, habits, goals, calendar, insights, notes, assistant, and appearance settings under frontend/src/app/. Global styles and theme provisioning are defined in frontend/src/app/globals.css and frontend/src/components/ThemeProvider.tsx; responsive navigation includes frontend/src/components/MobileNav.tsx.
API Boundary
Browser-side feature pages call the FastAPI service through the centralized client in frontend/src/lib/api.ts. This is the main frontend/backend boundary: UI state and interactions are translated into HTTP requests, while backend routers expose domain-specific API surfaces. The frontend is a React/TypeScript runtime; the backend is Python/FastAPI, normally served via Uvicorn on port 8000.
Backend Composition and Persistence
backend/main.py constructs the FastAPI application and integrates route modules. backend/database.py owns SQLAlchemy/SQLite connectivity and session infrastructure. Persistent entities and their relationships are represented in backend/models.py, while API request/response contracts are separated into backend/schemas.py. This keeps HTTP payload validation distinct from database representation.
Productivity Domain APIs
Core CRUD and tracking capabilities are partitioned by resource:
• Tasks: backend/routers/tasks.py, surfaced through task UI and reusable task workflows in frontend/src/app/tasks/page.tsx and frontend/src/components/TaskCard.tsx.
• Habit adherence: backend/routers/non_negotiables.py and frontend/src/app/non-negotiables/page.tsx.
• Goals and notes: backend/routers/goals.py, backend/routers/notes.py, with corresponding pages.
• User-facing preferences: backend/routers/settings.py and frontend/src/app/appearances/page.tsx.
Task priority ordering and completion activity feed the dashboard and downstream analytics.
Metrics, Insights, and Calendar Flow
backend/routers/metrics.py aggregates persisted completion and habit data into consistency scores and streak-oriented outputs. The frontend renders these outputs in frontend/src/app/insights/page.tsx and frontend/src/app/calendar/page.tsx, using Recharts per the project stack. This is the reporting boundary between raw operational records and derived progress views.
AI Coaching and Weekly Reports
AI operations are isolated in backend/routers/ai.py, using Google Gemini 1.5 Flash through google-generativeai and a GEMINI_API_KEY environment variable. Dashboard/assistant experiences consume generated motivation or guidance through frontend/src/app/assistant/page.tsx and the main dashboard. backend/routers/reports.py generates weekly AI-authored PDF reports using FPDF2, drawing from task completion, streak, and habit-adherence data for download/review.
Infrastructure
Development is orchestrated as separate frontend and backend processes, with docker-compose.yml providing container-oriented deployment composition. SQLite avoids a separate database service; Google Gemini is the material external dependency and requires API-key configuration.
Main entry points: layout.tsx App shell & theme · api.ts API client · main.py FastAPI application · models.py Persistence models
Components 20
Next.js frontend
React/TypeScript App Router UI.
- App shell & theme · Provides global styling, theme, and responsive navigation.
frontend/src/app/layout.tsx - Dashboard · Primary daily productivity view.
frontend/src/app/page.tsx - Task workflows · Task page and reusable task cards.
frontend/src/app/tasks/page.tsx - Habits
frontend/src/app/non-negotiables/page.tsx - Goals & notes
- Insights & calendar · Renders derived metrics and progress views.
frontend/src/app/insights/page.tsx - Assistant
frontend/src/app/assistant/page.tsx - Appearance settings
frontend/src/app/appearances/page.tsx - API client · Centralized browser-to-backend boundary.
frontend/src/lib/api.ts
FastAPI backend
Python API and domain processing.
- FastAPI application · Constructs the API and registers routers.
backend/main.py - Productivity APIs · Tasks, habits, goals, notes, and settings CRUD.
backend/routers/tasks.py - Metrics API · Calculates consistency scores and streak outputs.
backend/routers/metrics.py - AI coaching API · Generates motivation and guidance.
backend/routers/ai.py - Weekly reports API · Builds AI-authored PDF weekly reports.
backend/routers/reports.py - API schemas · Separates payload validation from persistence models.
backend/schemas.py - Persistence models · Defines persistent entities and relationships.
backend/models.py
Data and external services
- Database sessions · Owns SQLite connectivity and sessions.
backend/database.py - SQLite store
- Google Gemini 1.5 Flash · Requires GEMINI_API_KEY.
- Container composition · Runs frontend and backend processes for container deployment.
docker-compose.yml
Connections 29
- App shell & theme → Dashboard: hosts
- App shell & theme → Task workflows: hosts
- App shell & theme → Habits: hosts
- App shell & theme → Goals & notes: hosts
- App shell & theme → Insights & calendar: hosts
- App shell & theme → Assistant: hosts
- App shell & theme → Appearance settings: hosts
- Dashboard → API client: loads daily data
- Task workflows → API client: CRUD requests
- Habits → API client: adherence requests
- Goals & notes → API client: CRUD requests
- Insights & calendar → API client: requests metrics
- Assistant → API client: coaching requests
- Appearance settings → API client: preference requests
- API client → FastAPI application: HTTP
- FastAPI application → Productivity APIs: routes to
- FastAPI application → Metrics API: routes to
- FastAPI application → AI coaching API: routes to
- FastAPI application → Weekly reports API: routes to
- Productivity APIs → API schemas: validates payloads
- Productivity APIs → Persistence models: reads and writes
- Metrics API → Persistence models: aggregates activity
- Weekly reports API → Persistence models: uses completion data
- AI coaching API → Google Gemini 1.5 Flash: generates coaching
- Weekly reports API → Google Gemini 1.5 Flash: authors report content
- Persistence models → Database sessions: uses sessions
- Database sessions → SQLite store: connects to
- Container composition → App shell & theme: deploys frontend
- Container composition → FastAPI application: deploys backend