Technical Architecture Document · March 2026

Software Architecture Analysis

AI Story Companion Ecosystem — Hybrid Edge-Cloud Architecture

1. Architectural Overview

The AI Story Companion platform requires a hybrid edge-cloud architecture. The StoryCube device runs lightweight local inference and audio processing on-device (edge), while complex AI tasks — story generation, illustration, music — are offloaded to cloud services. This approach balances latency, offline capability, cost, and performance.

1.1 AI Processing Pipeline

#StageComponentLocationTechnology
1Voice InputWake word + VADEdge (device)TensorFlow Lite / Porcupine
2Speech-to-TextASR EngineEdge + Cloud fallbackWhisper (local small) / Google STT
3Safety CheckContent FilterCloudLLM guard / custom classifier
4Story OrchestratorNarrative ManagerCloudLLM (GPT-4o / Claude 3 Sonnet)
5Memory RetrievalVector StoreCloudPinecone / pgvector
6Language ModelStory GeneratorCloudAnthropic / OpenAI API
7Music EngineAdaptive AudioHybridMusicGen / curated library
8Illustration EngineScene ImagesCloudDALL-E 3 / Stable Diffusion
9Text-to-SpeechVoice SynthesisCloud + Edge cacheElevenLabs / local TTS
10OutputAudio + ProjectionEdge (device)Custom renderer

2. System Components

2.1 Device Software (Embedded / Edge)

The StoryCube runs a custom Linux-based OS (Buildroot or Yocto). The embedded software stack handles: wake-word detection, audio I/O pipeline, local ASR fallback, BLE/Wi-Fi connectivity, projection control, LED ring animation, OTA firmware updates, and power management.

LayerComponentNotes
OSLinux (Yocto/Buildroot)Lightweight, minimal attack surface
RuntimePython 3.11 + asyncioMain application runtime
AudioPulseAudio / ALSAMicrophone array + speaker management
Wake WordPorcupine SDK (on-device)Always-on low power mode
Local ASRWhisper.cpp (tiny/base model)Offline fallback STT
Local TTSPiper / Coqui TTSCache common phrases offline
ConnectivityNetworkManager + BlueZWi-Fi + BLE management
Cameralibcamera + OpenCVFace/object detection, scene capture
OTAMender / SWUpdateSecure firmware update delivery
SecurityTPM 2.0 + LUKS encryptionSecure boot + storage encryption

2.2 Cloud Backend

The cloud backend is designed as a set of microservices deployed on Kubernetes, with a focus on horizontal scalability, fault isolation, and independent deployment cycles.

ServiceResponsibilityTech Stack
API GatewayAuth, rate limiting, routingKong / AWS API Gateway
Auth ServiceJWT, OAuth2, device registrationPython/FastAPI + Keycloak
Story OrchestratorNarrative state machine, LLM callsPython/FastAPI + LangChain
Memory ServiceChild profile, story history, vector searchPostgreSQL + pgvector / Pinecone
Content SafetyAI output moderation, age filterPython + custom LLM classifier
Music ServiceDynamic music selection and generationPython + MusicGen / S3 library
Illustration ServiceScene image generationPython + DALL-E 3 / SD API
TTS ServiceVoice synthesis, cachingPython + ElevenLabs / Azure TTS
OTA ServiceFirmware update orchestrationGo + Mender API
Parent App APIProfile mgmt, controls, analyticsPython/FastAPI
Analytics ServiceUsage tracking, sleep reportsPython + ClickHouse
Notification ServicePush notifications, email summariesPython + FCM / SendGrid

2.3 Mobile Application (Parent App)

Cross-platform mobile app (iOS + Android) built with React Native + Expo. Communicates with StoryCube over BLE (setup/config) and with cloud backend over REST/HTTPS. Features: child profile management, content controls, bedtime schedules, sleep summary reports, story history, subscription management.

3. Data Architecture

The platform handles sensitive data about children, requiring careful data architecture with privacy by design.

Data TypeStorageRetentionCompliance
Child profiles & preferencesPostgreSQL (encrypted)Account lifetimeGDPR/COPPA
Story history & memorypgvector + PostgreSQL12 months rollingGDPR
Voice recordingsProcessed in-flight, NOT storedReal-time onlyCOPPA compliant
Sleep motion dataTime-series DB (InfluxDB)30 days + aggregatedGDPR
Usage analytics (anonymised)ClickHouse24 monthsGDPR Art. 89
Generated illustrationsS3 with per-child prefix30 daysGDPR
Firmware binariesS3 + CDNAll versions retainedInternal
Auth tokensRedis (short TTL)15min access / 7d refreshOWASP

4. Security Architecture

Given the child-facing nature of the product, security is a first-class concern at every layer.

Device Security

Secure boot (TPM 2.0), encrypted storage (LUKS), signed firmware updates, no debug ports in production, certificate pinning for cloud comms.

API Security

mTLS for device-to-cloud, JWT with short expiry, rate limiting per device/account, OWASP Top 10 hardening.

AI Content Safety

Multi-layer: system prompt guardrails → LLM content classifier → output post-processing → age-appropriate filter → parent override.

Privacy

No voice recording storage (COPPA), GDPR data subject rights API, parental consent flows, right-to-erasure implemented.

Network Security

All traffic TLS 1.3+, VPC isolation for services, WAF on API Gateway, DDoS protection via Cloudflare.

5. Scalability & Reliability

99.9%
API Uptime SLA
<800ms
Story Response Latency (p95)
100K+
Active Devices Supported
Auto-scaling microservices on Kubernetes (EKS/GKE), multi-region active-passive failover, CDN-delivered media assets (illustrations, audio). Monitoring via Prometheus + Grafana + PagerDuty.