TeachWise.ai Platform
Complete Technical Setup & Infrastructure Guide
┌─────────────────────────────────────────────────────────────┐
│ CLIENT LAYER │
├─────────────────┬─────────────────┬────────────────────────┤
│ Web App │ Mobile App │ Mobile App │
│ (React/Next.js)│ (iOS - Swift) │ (Android - Kotlin) │
└────────┬────────┴────────┬────────┴──────────┬─────────────┘
│ │ │
└─────────────────┼────────────────────┘
│
┌──────────────────────────▼─────────────────────────────────┐
│ API GATEWAY LAYER │
│ (AWS API Gateway / Kong / Express Gateway) │
│ - Rate Limiting - Authentication - Request Routing │
└──────────────────────────┬─────────────────────────────────┘
│
┌─────────────────┼─────────────────┐
│ │ │
┌────────▼────────┐ ┌─────▼──────┐ ┌───────▼────────┐
│ Auth Service │ │ AI Service │ │ Core API │
│ (Next-Auth/ │ │ (OpenAI/ │ │ (Node.js/ │
│ Firebase) │ │ Anthropic) │ │ Python) │
└────────┬────────┘ └─────┬──────┘ └───────┬────────┘
│ │ │
└────────────────┼──────────────────┘
│
┌─────────────────────────▼──────────────────────────────────┐
│ DATA LAYER │
├──────────────┬────────────────┬────────────────────────────┤
│ PostgreSQL │ MongoDB │ Redis Cache │
│ (User data, │ (Curriculum, │ (Sessions, │
│ schedules) │ resources) │ API responses) │
└──────────────┴────────────────┴────────────────────────────┘
│
┌─────────────────────────▼──────────────────────────────────┐
│ EXTERNAL SERVICES │
├──────────────┬────────────────┬────────────────────────────┤
│ Cloud School│ Gmail API │ Payment Gateway │
│ Integration │ (OAuth 2.0) │ (Stripe/M-Pesa) │
└──────────────┴────────────────┴────────────────────────────┘
Architecture Philosophy:
Microservices-based architecture for scalability, with clear separation of concerns and API-first design. Start with managed services (Firebase, AWS) to reduce operational overhead, then migrate to custom infrastructure as needed.
Primary: Claude Sonnet 4.5
Lesson plans, curriculum queries, complex reasoning
Cost: ~$3 per 1M input tokens, $15 per 1M output tokens
Secondary: Claude Haiku 4
Quick responses, simple queries, chatbot
Cost: ~$0.25 per 1M input tokens, $1.25 per 1M output tokens
Pros:
Cons:
💡 Cost Optimization Strategy:
Fine-tune models specifically for Kenyan/Ugandan curricula on your own infrastructure.
Recommended Models:
Benefits:
Combine existing APIs with vector database for curriculum-specific knowledge.
Stack:
API Costs (50K users):
$25,000-75,000/month
Self-hosted (50K users):
$8,000-15,000/month
Savings:
$10,000-60,000/month
🎯 Recommendation:
Start with Anthropic API, implement RAG at 1,000 users, and consider self-hosting at 20,000+ users when economics justify infrastructure investment.
Web Application
Mobile Apps
API Server
Authentication
Relational Data
• PostgreSQL 15+ (users, schedules, subscriptions)
• ORM: Prisma or Drizzle ORM
Document Storage
• MongoDB (curriculum, resources, lesson plans)
• ODM: Mongoose
Caching
• Redis (sessions, API responses, rate limiting)
File Storage
• AWS S3 / CloudFlare R2 (PDFs, images, resources)
Hosting (MVP)
• Vercel (Next.js frontend)
• Railway/Render (API server)
• Supabase/Neon (managed PostgreSQL)
Hosting (Scale)
• AWS/GCP (ECS, Cloud Run, or Kubernetes)
• CloudFlare (CDN, DDoS protection)
Monitoring
• Sentry (error tracking)
• DataDog/NewRelic (APM)
• PostHog (product analytics)
Connect to Cloud School's API to fetch student data, grades, and attendance by grade level.
Integration Flow:
API Endpoints Needed:
/api/auth/cloudschool/api/classes/api/students/api/grades/api/attendanceData to Sync:
Git Repository
GitHub (private repo) with branch protection
CI/CD Pipeline
GitHub Actions for automated testing & deployment
Environments
Development → Staging → Production
Unit Tests
Jest, Vitest (80% coverage target)
Integration Tests
Playwright, Cypress for E2E
AI Testing
LangSmith for LLM response evaluation
| Service | Monthly Cost |
|---|---|
| Vercel (hosting) | $20 |
| Railway/Render (API) | $20-50 |
| Supabase (database) | $25 |
| Anthropic API (AI) | $200-500 |
| Redis (Upstash) | $0-10 |
| CloudFlare R2 (storage) | $5-15 |
| Monitoring (Sentry, PostHog) | $50 |
| Total Monthly | $320-670 |
| Service | Monthly Cost |
|---|---|
| AWS/GCP (compute + database) | $500-1,000 |
| Anthropic API + RAG | $3,000-5,000 |
| Storage (S3/R2) | $100-200 |
| Vector DB (Pinecone) | $150-300 |
| CDN (CloudFlare) | $200 |
| Monitoring & Analytics | $300-500 |
| Total Monthly | $4,250-7,200 |
| Service | Monthly Cost |
|---|---|
| AWS/GCP (infrastructure) | $3,000-5,000 |
| Self-hosted AI (GPUs) | $8,000-12,000 |
| Storage & CDN | $500-1,000 |
| Database (managed) | $1,000-2,000 |
| Monitoring & Security | $1,000-1,500 |
| Total Monthly | $13,500-21,500 |
© 2025 TeachWise.ai Technical Documentation
Version 1.0 - Last Updated: November 2025