How remodik/lentik works
1. Repo shape
- This is a three-part product: a FastAPI backend in services/api, a Next.js web app in services/web, and a React Native mobile app in mobile.
- infra/docker-compose.yml ties the deployable services together for local/runtime orchestration, with PostgreSQL as the main shared datastore.
2. Backend is the system of record
- The API service is a single FastAPI monolith organized by domain routers rather than microservices.
- app/main.py is the entry point; routers/ exposes feature APIs, models/ defines persistence entities, schemas/ defines request/response contracts, and services/ holds cross-cutting business workflows.
3. Core data store and schema management
- Persistent application state lives in PostgreSQL 16.
- Schema evolution is managed with Alembic migrations under services/api/alembic/versions, showing a long-lived relational model that has evolved through chat, media, calendar, budgeting, roles, audit, and family-tree features.
4. Authentication and session boundary
- Auth is not just email/password: the README and code structure indicate login + PIN, JWT issuance, and persistent sessions.
- Security concerns are separated into core/security.py, core/jwt.py, core/sessions.py, core/rate_limit.py, and auth dependencies in auth/deps.py.
- This makes authentication, session validation, and authorization distinct concerns before domain logic runs.
5. Authorization and family-scoped access
- The app is built around families as the main tenant boundary.
- Permissions are richer than a simple member/admin split: there are roles, permission overrides, and related services for role management.
- The presence of family join, invites, and member/role routers suggests most API access is gated by family membership plus per-resource permissions.
6. Realtime communication layer
- Chat is a major subsystem with realtime messaging, read receipts, reactions, mentions, attachments, pinned messages, and channel settings.
- Realtime delivery is handled separately via app/ws/manager.py, while ws_tickets.py in core suggests short-lived WebSocket authorization tickets.
- Presence is part of the backend data model, so online status is treated as shared server state rather than only client UI state.
7. Shared media and file pipeline
- Uploads are a first-class backend concern: there is a dedicated uploads router and core/uploads.py.
- UPLOAD_DIR in the root README indicates file storage is filesystem-based rather than an external object store.
- Gallery items, chat attachments, and media metadata are modeled separately, so the architecture distinguishes between file blobs and application records about those files.
8. Business domains beyond chat
- The backend is a broad family hub, not just a messenger.
- Feature domains include calendar events and reminders, budget/expenses/transactions, notes, family tree layout, audit logging, and membership/invite flows.
- services/ contains workflows like reminders dispatching, calendar reminder generation, invite handling, and audit recording, implying these are coordinated server-side processes rather than purely client-driven screens.
9. Web frontend architecture
- The web app is a Next.js 15 application using the App Router structure in src/app/.
- UI is composed from feature components under src/components/, with supporting hooks and API wrappers in src/lib/.
- The web client includes a notification system, theme provider/selector, mobile navigation, and a service worker in public/sw.js, so it behaves like a responsive app with PWA-style capabilities.
10. Mobile frontend architecture
- The mobile app is a separate React Native client with its own navigation, screens, contexts, and component set.
- AuthContext and FamilyContext indicate shared global state for login/session and current-family selection.
- Feature API modules under mobile/src/api/ mirror the backend domains, showing the mobile app is a thin client over the same backend contract.
11. Client-to-server data flow
- Both web and mobile clients talk to the FastAPI backend through HTTP APIs, using feature-specific API wrappers rather than direct server coupling.
- Chat and presence additionally rely on the backend’s WebSocket path for low-latency updates.
- The backend then persists state in PostgreSQL and, for uploads, stores file content on disk while keeping metadata in the database.
12. Operational boundary
- infra/docker-compose.yml is the primary local integration boundary, assembling the backend, frontend, and database with environment-based configuration.
- The repository is structured so that deployment concerns stay mostly outside the feature code: app logic lives in services/api, services/web, and mobile, while infra handles composition and runtime wiring.
Main entry points: routers Routers · docker-compose.yml Compose · main.py API entry · manager.py WS manager
Components 19
Infra
Local composition and runtime wiring
- Compose · Local service assembly and env wiring
infra/docker-compose.yml - Postgres · Primary shared datastore for application state
Backend
FastAPI monolith and persistence
- API entry · Monolithic backend application bootstrap
services/api/app/main.py - Auth core · Login, PIN, JWT, sessions, rate limiting, upload and WS ticket controls
services/api/app/core - Auth deps · Authentication and authorization dependencies
services/api/app/auth/deps.py - Routers · Domain routers exposing the backend surface
services/api/app/routers - Workflows · Cross-cutting server workflows and coordinators
services/api/app/services - Models · Persistence entities for families, chat, calendar, budgets, roles, and audit
services/api/app/models - Schemas · Request and response payload definitions
services/api/app/schemas - WS manager · WebSocket connection and broadcast management
services/api/app/ws/manager.py - Migrations · Alembic database evolution for the relational model
services/api/alembic/versions
Web app
Next.js client and UI
- Next app · App Router web frontend
services/web/src/app - Web UI · Feature views, modals, navigation, theme, and notifications
services/web/src/components - Web lib · API wrappers, presence, permissions, and hooks
services/web/src/lib - Service worker · Background caching and notification support
services/web/public/sw.js
Mobile app
React Native client
- Mobile nav · Native navigation and screen composition
mobile/src/navigation/RootNavigator.js - App state · Auth and family selection state boundaries
mobile/src/context - Mobile API · Feature-specific HTTP clients for backend domains
mobile/src/api - Screens · Native feature screens for chat, budget, gallery, reminders, and profile
mobile/src/screens
Connections 27
- Compose → API entry: runs · Compose starts the backend service
- Compose → Postgres: provisions · Compose wires the database service
- Compose → Next app: runs · Compose starts the web client
- Compose → Mobile nav: supports · Local environment also supports the mobile client
- API entry → Auth core: uses · App startup relies on security and session boundaries
- API entry → Auth deps: protects · Routes are guarded by auth dependencies
- API entry → Routers: mounts · Main app registers domain routers
- Routers → Workflows: orchestrates · Routers delegate workflows to service layer
- Routers → Models: persists · Routers operate on domain entities
- Routers → Schemas: validates · Routers exchange typed request/response contracts
- Workflows → Models: reads/writes · Workflows coordinate persistent state
- Workflows → Auth core: checks · Business actions depend on session and permission rules
- WS manager → Auth core: authorizes · WebSocket access uses short-lived tickets and security checks
- Models → Postgres: stored in · ORM state is persisted in PostgreSQL
- Migrations → Postgres: evolves · Alembic tracks schema changes in the database
- WS manager → Models: streams · Realtime features reflect presence and message state
- Next app → Web UI: composes · App Router pages are built from feature components
- Next app → Web lib: calls · Pages use shared client logic and API bindings
- Web UI → Web lib: depends on · UI components use hooks and API helpers
- Web UI → Service worker: enhanced by · Notifications and PWA behavior are supported in the browser shell
- Mobile nav → App state: shares state · Navigation relies on auth and family contexts
- Mobile nav → Screens: renders · Navigator selects feature screens
- Screens → Mobile API: calls · Screens use domain API modules
- Mobile API → Routers: talks to · Mobile client consumes backend HTTP endpoints
- Web lib → Routers: talks to · Web client consumes backend HTTP endpoints
- Web lib → WS manager: subscribes · Web client also participates in realtime updates
- Mobile API → WS manager: subscribes · Chat and presence can use realtime backend updates