Anora

Privacy-first wellness journaling with on-device ML inference that syncs across devices without a server in between.

02 / TRUST BOUNDARYARCHITECTURE / FIELD NOTES
The journal never crosses the frame.local inference · encrypted reporting · masked learning01DEVICEFlutter + TFLite02INFERENCEINT8 MentalBERT03PRIVACY GUARDAES / SecAgg04BLIND MAILMANFastAPI coordinator
01DEVICEFlutter + TFLite
02INFERENCEINT8 MentalBERT
03PRIVACY GUARDAES / SecAgg
04BLIND MAILMANFastAPI coordinator
02 / TRUST BOUNDARY / The journal never crosses the frame.
FIELD NOTES CONTINUE
RUNTIMEOct 2025 - May 2026
FORMATFlutter / FastAPI / PostgreSQL / TFLite
RUN ONAWS App Runner, on-device ARM
STATUSShipped

The problem: College students report worsening mental health during exam seasons, but existing journaling apps route sensitive entries through cloud services before insights surface. The privacy cost of the insight is too high.

The constraint: On-device inference had to fit within a 10MB app bundle and stay under 200ms on a mid-range Android phone. The model also had to generalize across three languages: English, Hindi, and Marathi, with zero cloud round-trips.

What I built: Anora stacks a quantized INT8 MentalBERT encoder inside a TFLite flatbuffer, running entirely in the Flutter process via the tflite_flutter plugin. The FastAPI backend handles only encrypted sync payloads and aggregate analytics. I implemented federated learning with secure aggregation using TensorFlow Federated so the shared model improves without any device exposing its journal entries.

The design decision is local-first by default: raw journal text, AES-256 encrypted storage, and inference remain on the device. The backend is a blind mailman for encrypted clinician reports and a coordinator for masked federated updates. It never needs to read the journal to support sync, monitoring, or model improvement.

The architecture splits responsibilities cleanly: device-side inference returns sentiment, emotion tags, and reflection prompts locally. The server stores only encrypted blobs keyed by device salt. The shared aggregator model trains on synthetic gradients that are aggregated before hitting the coordinator.

A second tradeoff: I shipped with English-only prompts first to hit the inference budget. Hindi and Marathi support landed six weeks later as a smaller update, which meant early adopters got a less useful experience.

Data classification legend — what can transit the wire vs. what is physically confined to the device:

Classification Example Constraint
Raw PHI (red) Journal text Never leaves the device
ML/Derived (green) Mood scores, risk flags, masked gradients Masked for FL, encrypted for clinician reports
Encrypted (blue) AES-wrapped JSON, RSA-wrapped key Server sees only opaque blobs via Blind Mailman
Security (yellow) Keys, privacy guards Keys generated on-device, never leave it

Cryptography: AES-256-GCM for data at rest (SQLCipher/Realm Encryption), RSA-2048 for doctor-patient key exchange, iOS Secure Enclave / Android Keystore for key storage. A privacy-guard interceptor blocks any outbound request that doesn't validate as an encrypted blob or masked numeric vector — raw journal text can never leak.

Production deployment: Backend lives on AWS App Runner behind CloudFront CDN, with managed PostgreSQL and AES-256 encrypted report storage. The federated learning coordinator exposes client registration, masked gradient submission, and model distribution endpoints. CORS defaults to the CloudFront origin to prevent unauthorized frontend access.

Numbers:

Metric Value Baseline
On-device inference time 180ms 420ms (FP32 baseline)
Model size reduction 88% 92MB FP32 model
Sync latency (offline-capable) 0ms N/A, cloud-only sync
Accuracy on emotion classification 84.3% 71.2% (rule-based keyword matching)
Battery impact per session 2.1% 5.4% (cloud round-trip + server)

What broke: The first federated round used a fixed learning rate of 0.01, which caused client drift on devices with sparse journaling patterns. The model overfit to a handful of enthusiastic early testers and degraded sentiment tagging for infrequent writers. Rolling back to per-client adaptive rates fixed it, at the cost of two weeks of delayed training cycles.

The second failure was more expensive: the initial TFLite delegate allocation was static, so on low-RAM phones the app crashed during onboarding. The fix required switching to dynamic delegates and deferring model load until after the first successful sync. That pushed the first release back by ten days.

What I'd do differently: Start the multilingual prompt generation earlier. The English-only launch created churn that would have been avoidable with a language-agnostic prompt template system from the beginning.

Links:

Repository ↗