How aakash-kr-7/sol works
1. Top-level architecture
- This repo is a two-part MVP: a Flutter client in frontend/companion_app and a FastAPI backend in backend.
- The product is centered on a persistent AI companion with long-lived memory, relationship state, proactive outreach, and privacy controls.
2. Client boundary
- The Flutter app is the presentation and session layer for auth, onboarding, chat, inbox, memory vault, profile/privacy, settings, and companion-specific UX.
- Platform support is broad: Android, iOS, web, macOS, Windows, and Linux are all scaffolded, but the app logic lives primarily in lib/.
- The client talks to the backend through lib/services/api_service.dart and related services, not directly to any data store.
3. Authentication and session bootstrap
- Authentication is Firebase-backed on the client and server-verified in the backend.
- backend/auth/firebase.py handles token verification, while the Flutter side uses auth_service.dart, session_bootstrap_service.dart, and biometric_service.dart to establish user/session state.
- This creates a hard boundary between device identity, Firebase identity, and the backend’s pair-scoped application identity.
4. Backend API surface
- The backend is organized as route modules under backend/api: chat, profile, onboarding, notifications, proactive, and ops.
- These are the main external entry points and map cleanly to product concerns: conversation, user state, first-run setup, notification delivery, proactive messaging, and admin visibility.
- backend/main.py is the API composition root that wires these routes into the FastAPI app.
5. Conversation orchestration
- Chat is not just message forwarding; it is orchestrated through backend/core/chat-style responsibilities spread across context_builder.py, llm.py, summarizer.py, burst_engine.py, and concurrency.py.
- The architecture suggests the backend prepares rich context, calls an LLM, then returns response content with pacing/burst metadata for the client to render as a believable companion interaction.
- frontend/companion_app/lib/services/burst_playback_service.dart and UI widgets like typing_indicator.dart and message_bubble.dart support that playback model.
6. Memory system
- Persistent memory is a first-class subsystem under backend/memory, with separate components for extraction, analysis, consolidation, retrieval, storage, and relationship inference.
- This likely forms the long-term continuity engine: short-term conversation signals are distilled into durable memory objects and relationship state.
- The repo also includes backend/db/schema.sql and backend/DATA_MODEL.md, indicating the memory/relationship model is explicitly designed rather than incidental.
7. Relationship and personalization layer
- backend/personality contains character definitions in JSON and a loader/registry, which means the app supports multiple companions rather than a single generic persona.
- This layer is a content boundary: character identity, tone, and behavioral rules are data-driven and separated from core orchestration logic.
- It aligns with the “multi-companion roster” described in the README and the character-focused screens in the Flutter app.
8. Proactive behavior
- Proactive engagement is isolated in backend/core/proactive_engine.py and exposed through backend/api/proactive.py and backend/api/notifications.py.
- Supporting files like backend/core/life_simulator.py and backend/core/burst_engine.py suggest the backend can simulate or schedule companion-driven outreach rather than waiting only for user-initiated chat.
- On the client, notification_service.dart, notification_hooks_service.dart, and inbox-related screens reflect that the user may receive asynchronous engagement.
9. Profile, transparency, and privacy controls
- The Flutter app has dedicated screens for profile, privacy, about, vault, relationship studio, and settings, which correspond to backend endpoints under profile and ops.
- This indicates the system is designed around user agency: inspectable memory, reset/delete paths, and transparency controls are part of the product architecture, not add-ons.
- The “memory vault” and “relationship studio” are especially important architectural surfaces because they expose internal state to the user.
10. Ops and validation boundary
- backend/api/ops.py, backend/inspect_db.py, backend/tests/, and backend/scripts/test_proactive.py show there is explicit operational and test tooling around the backend.
- The backend is intended to run on Railway, with backend/Procfile and backend/railway.json providing deployment configuration.
- The README also notes live startup and smoke testing still matter, which means architecture exists, but runtime validation is a separate concern.
11. Data and persistence
- The presence of schema.sql, memory store modules, and DB inspection tooling suggests a local relational persistence layer for user state, relationship state, and memory records.
- Local/generated storage is treated as disposable or environment-specific; the repo hygiene notes mention avoiding committed database artifacts and a chroma_db directory, implying optional vector/memory persistence may exist in local development.
- The key architectural point is that all durable state is backend-owned and pair-scoped, not embedded in the Flutter client.
12. Cross-cutting runtime model
- The overall flow is: user authenticates in Flutter, the backend verifies identity, chat requests are enriched with memory and relationship context, the LLM generates a paced response, and the backend updates long-term state.
- Separately, proactive systems can generate outbound engagement and notifications based on stored state and scheduling logic.
- That gives the system three major boundaries: client presentation, backend cognitive/memory orchestration, and persistent identity/state.
Main entry points: api_service.dart API client · main.py API app · context_builder.py Context builder · main.dart App shell
Components 24
Flutter client
Cross-platform companion app UI and session layer.
- App shell · Bootstraps the companion app and routes into the UI.
frontend/companion_app/lib/main.dart - Auth flow · Handles sign-in, device/session state, and biometric gating.
frontend/companion_app/lib/services/auth_service.dart - Session bootstrap · Establishes persisted user and companion session state after launch.
frontend/companion_app/lib/services/session_bootstrap_service.dart - API client · Central network boundary for chat, profile, onboarding, and notifications.
frontend/companion_app/lib/services/api_service.dart - Burst playback · Renders paced companion responses and typing-like interaction.
frontend/companion_app/lib/services/burst_playback_service.dart - Notifications · Coordinates inbox-style prompts and device notification handling.
frontend/companion_app/lib/services/notification_service.dart - Onboarding · Guides new users through setup and companion introduction.
frontend/companion_app/lib/screens/onboarding_screen.dart - Chat screen · Primary companion interaction surface for messages and pacing.
frontend/companion_app/lib/screens/chat_screen.dart - Inbox · Surfaces proactive outreach, notifications, and message entry points.
frontend/companion_app/lib/screens/inbox_screen.dart - Memory vault · Exposes user-visible memory and stored relationship state.
frontend/companion_app/lib/screens/memory_vault_screen.dart - Privacy & profile · Contains privacy, about, settings, and relationship management surfaces.
frontend/companion_app/lib/screens/privacy_screen.dart
FastAPI backend
API, orchestration, memory, and persistence services.
- API app · Composes the backend application and mounts the route modules.
backend/main.py - Firebase auth · Verifies Firebase identity before backend-scoped access is granted.
backend/auth/firebase.py - Chat API · External chat entry point for companion conversation requests.
backend/api/chat.py - Profile API · User-state and privacy-related backend entry point.
backend/api/profile.py - Onboarding API · Supports first-run setup and companion initialization.
backend/api/onboarding.py - Notifications API · Delivers notification-facing backend actions and inbox signals.
backend/api/notifications.py - Proactive API · Exposes outbound engagement and scheduled companion behavior.
backend/api/proactive.py - Ops API · Operational visibility and maintenance entry point.
backend/api/ops.py - Context builder · Assembles rich conversation context from state and memory.
backend/core/context_builder.py - LLM core · Generates companion responses from enriched context.
backend/core/llm.py - Memory pipeline · Extracts, consolidates, retrieves, and stores long-term memory and relationship signals.
backend/memory/store.py - Persona registry · Loads and serves companion character definitions and behavior profiles.
backend/personality/registry.py - Proactive engine · Schedules or triggers companion-initiated outreach.
backend/core/proactive_engine.py
Connections 28
- App shell → Auth flow: bootstraps · App launch establishes authentication and session state.
- App shell → Onboarding: routes to · New users are guided into onboarding.
- App shell → Chat screen: opens · Authenticated users enter the main companion chat experience.
- Chat screen → API client: sends · Conversation and state changes are sent through the API client.
- Inbox → Notifications: listens to · Inbox UI reflects notification and proactive engagement state.
- Privacy & profile → Memory vault: surfaces · User controls expose inspectable memory and privacy surfaces.
- Burst playback → Chat screen: renders · Paced delivery shapes the conversation UI.
- API client → Firebase auth: authenticates · Client requests are accepted only after backend identity verification.
- API client → Chat API: calls · Chat traffic goes through the chat route module.
- API client → Profile API: calls · Profile, privacy, and user-state updates go through profile routes.
- API client → Onboarding API: calls · First-run setup uses onboarding routes.
- API client → Notifications API: calls · Notification state and inbox actions use notification routes.
- API client → Proactive API: calls · Proactive companion actions are requested through proactive routes.
- API client → Ops API: calls · Operational visibility is available through ops routes.
- API app → Chat API: mounts · Main app composes the chat route into FastAPI.
- API app → Profile API: mounts · Main app composes the profile route into FastAPI.
- API app → Onboarding API: mounts · Main app composes the onboarding route into FastAPI.
- API app → Notifications API: mounts · Main app composes the notifications route into FastAPI.
- API app → Proactive API: mounts · Main app composes the proactive route into FastAPI.
- API app → Ops API: mounts · Main app composes the ops route into FastAPI.
- Chat API → Context builder: builds · Chat requests are enriched before model generation.
- Context builder → Memory pipeline: retrieves · Context assembly pulls long-term memory and relationship signals.
- Context builder → Persona registry: applies · Context is shaped by the active companion persona.
- Context builder → LLM core: feeds · Prepared context is passed to the model layer.
- LLM core → Memory pipeline: updates · Generated interactions contribute to durable memory storage and consolidation.
- Proactive API → Proactive engine: drives · Route calls trigger proactive orchestration.
- Proactive engine → Memory pipeline: consults · Outbound behavior depends on stored memory and relationship state.
- Proactive engine → Notifications API: emits · Proactive events surface as notifications or inbox items.