Tech Stack Document: Duory Language Learning Companion


1. Overview

Project: Duory (Duolingo Companion App)
Description: Mobile application for language learners, featuring translation, romanization, kana support, and synchronization with Duolingo. Freemium model with subscription.


2. Core Technical Requirements

  • Cross-platform mobile support (iOS/Android)
  • Real-time translation & text processing
  • Secure Duolingo API integration
  • Offline functionality for note-taking
  • Subscription management
  • Data synchronization across devices

3. Technology Stack

Frontend (Mobile App)
  • Framework: React Native 0.73 (Expo SDK 49)
    • Rationale: Cross-platform efficiency, hot-reload, and access to native APIs via Expo modules.
  • State Management: Redux Toolkit 1.9.5
  • UI Library: NativeBase 3.4.0 (customizable components)
  • Navigation: React Navigation 6.x
  • Offline Storage: WatermelonDB 0.28.0 (local sync with backend)
Backend & APIs
  • Runtime: Node.js 20.x (LTS)
  • Framework: NestJS 10.0 (TypeScript-first, modular architecture)
  • Database: PostgreSQL 15 (primary), Redis 7.0 (caching/sessions)
  • Translation API: Google Cloud Translation API v3
  • Duolingo Integration: Reverse-engineered REST API (with OAuth 2.0)
  • Text Processing:
    • Romanization: kuroshiro (Japanese) + custom LibICU bindings
    • Kana Support: wanakana 5.0
Infrastructure & DevOps
  • Cloud Platform: AWS (EKS for Kubernetes)
  • CI/CD: GitHub Actions + Expo EAS Build
  • Containerization: Docker 24.x, Helm charts
  • Monitoring: Prometheus/Grafana + Sentry (error tracking)
  • Security: AWS KMS (encryption), Cloudflare WAF
Subscription & Payments
  • Payment Gateway: Stripe (React Native SDK 0.23.0)
  • Entitlements: AWS Cognito (user auth) + DynamoDB (subscription state)

4. Implementation Steps

Phase 1: Foundation
  1. Scaffold Mobile App:
    expo init duory-mobile --template expo-template-blank-typescript  
  2. Backend Setup:
    • NestJS boilerplate with TypeORM for PostgreSQL.
    • Configure Redis for rate limiting (20 req/sec/user).
Phase 2: Core Features
  1. Duolingo Sync:
    • Implement OAuth 2.0 flow via expo-auth-session.
    • Background sync using expo-task-manager.
  2. Translation Pipeline:
    • Google Translate API wrapper with Redis memoization (cache TTL: 24h).
    • Offline-first design: Queue unsent requests in WatermelonDB.
  3. Text Processing:
    • Integrate kuroshiro for Japanese romanization/kana (WebAssembly module).
Phase 3: Monetization & Security
  1. Subscription Flow:
    • Stripe Checkout embedded via React Native WebView.
    • AWS Lambda webhooks for payment events.
  2. Security Hardening:
    • JWT authentication with 15-minute expiry.
    • Automatic PII redaction in logs (NestJS Pino middleware).
Phase 4: Deployment
  1. CI/CD Pipeline:
    • Expo EAS for app store builds (automated TestFlight/Play Store submissions).
    • ArgoCD for Kubernetes rollouts (canary testing).

5. Scalability & Performance

  • Horizontal Scaling: Stateless backend pods in Kubernetes (auto-scaling based on CPU/RPS).
  • Data Sharding: User data partitioned by locale (e.g., en_users, jp_users).
  • Bundle Optimization: React Native code splitting using Metro splitChunks.
  • Load Testing: Locust scripts simulating 10k concurrent users.

6. Compliance & Risks

  • GDPR/CCPA: Anonymous analytics via Plausible.io, data deletion hooks.
  • Duolingo TOS: Rate-limited API calls (5 req/min/user), fallback to cached data.
  • Payment Compliance: PCI-DSS Level 1 via Stripe, no card data storage.

Estimated Development Timeline: 6 months (3 sprints)
Cost Optimization: AWS Spot Instances for non-prod, CloudFront caching for static assets.

Maintainability Note:

  • Monorepo structure (Turborepo) for shared TypeScript utils.
  • OpenTelemetry instrumentation for end-to-end tracing.

Revision: 1.0 | Date: 2023-10-05
Approved by Engineering Lead