How shahtiflain/the-last-minute-life-saver works
Purpose and system shape
Last-Minute Life Saver is an AI-assisted productivity and scheduling system. A React client manages tasks, goals, habits, focus blocks, analytics, and AI views; a Node/Express API owns application CRUD and authentication; a Python/FastAPI service executes a multi-agent planning pipeline. The system persists domain data in MongoDB Atlas and can schedule into Google Calendar and send Firebase notifications.
Entry points and deployment units
• Frontend Vite bootstrap and application shell: frontend/src/main.tsx, frontend/src/App.tsx.
• Backend Express application/server: backend/src/app.ts, backend/src/server.ts.
• AI FastAPI application: ai-orchestrator/app/main.py; an additional launcher exists at ai-orchestrator/main.py.
• Services are independently containerized and composed locally: frontend/Dockerfile, backend/Dockerfile, ai-orchestrator/Dockerfile, docker-compose.yml. Kubernetes manifests define corresponding deployable workloads under k8s/.
Frontend experience and client boundary
The React/TypeScript frontend presents routed productivity screens and dashboard widgets. frontend/src/components/layout/MainLayout.tsx supplies the authenticated application shell, while pages such as frontend/src/pages/Dashboard.tsx, frontend/src/pages/Tasks.tsx, and frontend/src/pages/AiCoach.tsx assemble feature views. Domain hooks (frontend/src/hooks/useTasks.ts, frontend/src/hooks/useGoals.ts) and the HTTP boundary in frontend/src/services/api.ts isolate UI components from backend REST APIs. Firebase client setup is at frontend/src/config/firebase.ts, including a messaging service worker at frontend/public/firebase-messaging-sw.js.
Application API, identity, and persistence
The Node/Express backend exposes separate route/controller layers for user productivity data and AI requests: backend/src/routes/task.routes.ts, backend/src/routes/goal.routes.ts, and backend/src/routes/ai.routes.ts, backed by their corresponding controllers. JWT/authentication enforcement is centralized in backend/src/middlewares/auth.middleware.ts. MongoDB models define the core durable domain—tasks, goals, habits, focus blocks, notifications, and users—e.g. backend/src/models/Task.ts, backend/src/models/Goal.ts, backend/src/models/User.ts; database connection is configured in backend/src/config/database.ts. The backend is the trust boundary between browser clients and internal AI orchestration, using an internal API key per the documented architecture.
AI orchestration pipeline
FastAPI routes in ai-orchestrator/app/api/routes.py accept AI-oriented requests and pass them to ai-orchestrator/app/core/orchestrator.py. The orchestrator coordinates registered specialist agents through ai-orchestrator/app/agents/agent_registry.py: the planner decomposes goals/tasks, risk analysis assesses deadline feasibility, and the scheduler constructs time blocks (planner_agent.py, risk_analyzer_agent.py, scheduler_agent.py). The watcher agent (watcher_agent.py) handles ongoing conflict/rescheduling intent. API schemas in ai-orchestrator/app/api/agent_schemas.py form the typed boundary for agent inputs and explainable outputs.
Agent state, model, and action boundaries
Agents derive common behavior from ai-orchestrator/app/agents/base_agent.py, use request-scoped/shared state in ai-orchestrator/app/memory/request_context.py and ai-orchestrator/app/memory/shared_memory.py, and load role-specific system prompts from ai-orchestrator/prompts/system/. Gemini is abstracted behind ai-orchestrator/app/llm/base_llm.py and implemented by ai-orchestrator/app/llm/gemini_client.py, keeping provider calls outside agent logic. External side effects are isolated as tools: Google Calendar interactions in ai-orchestrator/app/tools/calendar_tool.py and notification delivery in ai-orchestrator/app/tools/notification_tool.py.
Primary end-to-end flow
A user signs in through the frontend, then the frontend calls authenticated Express REST endpoints to create or retrieve productivity data. AI requests cross from the backend to FastAPI; the orchestrator invokes planner → risk analyzer → scheduler, sharing request context and using Gemini for reasoning. Results include explanations, confidence, and reasoning traces for UI presentation. The scheduler writes calendar blocks through Google Calendar; the watcher can detect/react to scheduling conflicts and trigger revised orchestration. MongoDB is the system-of-record boundary, while Firebase Cloud Messaging is the outbound notification channel.
Main entry points: agent_registry.py Specialist agents · orchestrator.py Planning orchestrator · ai.routes.ts AI request API · MainLayout.tsx Authenticated workspace
Components 21
React client
- React application
frontend/src/main.tsx - Authenticated workspace
frontend/src/components/layout/MainLayout.tsx - Productivity views
frontend/src/pages/Dashboard.tsx - AI Coach
frontend/src/pages/AiCoach.tsx - Domain hooks
frontend/src/hooks/useTasks.ts - HTTP client
frontend/src/services/api.ts - Firebase messaging
frontend/src/config/firebase.ts
Application API
- Express server
backend/src/server.ts - JWT authentication
backend/src/middlewares/auth.middleware.ts - Productivity API
backend/src/routes/task.routes.ts - AI request API · Internal-key boundary to orchestration.
backend/src/routes/ai.routes.ts - Domain models · Tasks, goals, habits, focus blocks, notifications, and users.
backend/src/models/Task.ts
AI orchestration
- FastAPI service
ai-orchestrator/app/main.py - Agent API schemas
ai-orchestrator/app/api/routes.py - Planning orchestrator
ai-orchestrator/app/core/orchestrator.py - Specialist agents
ai-orchestrator/app/agents/agent_registry.py - Request state
ai-orchestrator/app/memory/request_context.py
External services
- MongoDB Atlas
- Gemini model
- Google Calendar
- Firebase Cloud Messaging
Connections 25
- React application → Authenticated workspace: renders
- Authenticated workspace → Productivity views: hosts
- Authenticated workspace → AI Coach: hosts
- Productivity views → Domain hooks: uses
- Domain hooks → HTTP client: calls
- AI Coach → HTTP client: submits requests
- React application → Firebase messaging: initializes
- HTTP client → Express server: authenticated REST
- Express server → JWT authentication: enforces
- JWT authentication → Productivity API: permits
- JWT authentication → AI request API: permits
- Productivity API → Domain models: reads and writes
- Domain models → MongoDB Atlas: persists to
- AI request API → FastAPI service: internal AI request
- FastAPI service → Agent API schemas: serves
- Agent API schemas → Planning orchestrator: dispatches
- Planning orchestrator → Specialist agents: coordinates
- Planning orchestrator → Request state: shares context
- Specialist agents → Gemini model: reasons with
- Specialist agents → Google Calendar: schedules blocks
- Specialist agents → Firebase Cloud Messaging: sends alerts
- Firebase Cloud Messaging → Firebase messaging: delivers to
- Planning orchestrator → AI request API: explanations and plans
- AI request API → AI Coach: AI result
- Specialist agents → Planning orchestrator: conflict revisions