Nginx
Gateway
Provides one browser-facing origin and routes page, API, WebSocket, and static-file requests.
Loading route
Technical architecture
A concise, implementation-focused view for engineers, security reviewers, operators, and technical partners.
System map
The browser sees a single secure origin. Behind it, the gateway separates interactive web traffic from APIs while a dedicated scheduler handles time-based generation, embedding, and delivery.
Client
Family, patient, public, and administrator interfaces.
Application edge
Routes pages to Next.js and API calls to FastAPI.
Pages, forms, and client state
Domain APIs, security, and orchestration
Transactional data and vector search
Pre-generation, embedding jobs, timed delivery
LLMs, embeddings, image generation, and audio via OpenRouter
Email, SMS, news, weather, and media sources
Runtime components
The backend is a modular monolith: business domains share one API deployment and database, while background scheduling remains a separate process.
Nginx
Provides one browser-facing origin and routes page, API, WebSocket, and static-file requests.
Next.js + React + TypeScript
Renders public, family, patient, and administration experiences using the App Router.
FastAPI + Python
Owns authentication, authorization, business rules, provider orchestration, and JSON contracts.
APScheduler + FastAPI
Runs scheduled newsletter generation, RAG embedding jobs, and delivery independently from interactive requests.
PostgreSQL + SQLAlchemy + Alembic
Stores accounts, families, profiles, provider settings, newsletters, RAG vectors, billing, and scheduled jobs.
pgvector + PostgreSQL full-text
Hybrid semantic and lexical retrieval for story lore and family memories, co-located with transactional data.
Host-mounted filesystem
Holds generated media, uploads, cached audio, PDFs, logs, and other recoverable runtime artifacts.
AI and content capabilities
Little Daily Joys serves cognitive-care families with daily newsletters and serves writers with a storytelling workspace. Both draw on the same AI orchestration, cost tracking, and provider configuration layer.
90+ modular providers (comics, puzzles, weather, news, nostalgia, music, and more) assemble profile-driven newsletters. Deterministic providers run without AI; AI-assisted providers use configured models with caching, validation, and variety controls.
Family-authored memories and safe profile facts are chunked, embedded, and retrieved with hybrid vector + full-text search. Retrieved context is wrapped in an untrusted-data boundary, and generated prose is validated before it reaches a newsletter or memory chat.
Uploaded world documents are indexed into pgvector chunks. Story chat answers questions using hybrid retrieval with lexical fallback, and every query is logged for audit.
Worlds, characters, acts, scenes, brainstorming, and guided story wizards share one AI orchestration layer with per-user model configuration and cost attribution.
Published family stories can be narrated scene by scene. Audio is synthesized through OpenRouter, cached on the filesystem, and served with selectable narrator voices.
Newsletters and stories reach readers through email, SMS, PDF export, and the in-app reader, with per-family channel configuration.
Interactive request flow
The browser never needs an internal container hostname. Cookies and API requests stay on the application origin.
Requests a page or calls the same-origin /api/v1 interface.
Routes UI traffic to Next.js and API or WebSocket traffic to FastAPI.
Authenticate the caller, apply domain rules, and orchestrate work.
Read or write PostgreSQL and call configured external services when required.
Newsletter pipeline
Each provider produces a focused item using approved profile preferences, provider configuration, and — where enabled — retrieved family memories.
Retrieval-augmented generation
Two independent RAG subsystems share the same pgvector foundation but serve different products, with different indexing models and safety postures.
Asynchronous, durable, privacy-first
Synchronous, world-scoped
Security and data
Navigation controls improve usability, but authorization decisions are made by the backend. Secrets and provider credentials remain in environment-specific runtime configuration and are not shipped to the browser.
Browser sessions use an HttpOnly access-token cookie. API clients may use bearer authentication, and patient access has a separate ordered-picture flow.
FastAPI dependencies and ownership checks enforce active-user, family, patient, and administrator boundaries, including per-family RAG membership checks.
Prompt-injection defenses, output validation, provider allowlists, and per-user cost tracking apply to every AI-assisted path.
PostgreSQL holds transactional data and vectors. Alembic versions schema changes; runtime files and database volumes are backed up separately.
Deployment and operations
Docker Compose defines the application services. Development and production use environment-specific configuration, domains, data volumes, and credentials without changing application code.
| Concern | Development | Production |
|---|---|---|
| Entry point | Local Docker gateway | HTTPS host proxy to Docker gateway |
| Configuration | Development runtime environment | Production runtime environment with managed secrets |
| State | Dedicated development database and volumes | Dedicated persistent database and runtime volumes |
| Release safety | Unit, integration, build, and browser tests | Migrations, health checks, backups, and smoke checks |
This page describes the current high-level implementation. Internal route names may retain legacy Care Circle or Ink & Quill identifiers while the public product is Little Daily Joys.