Architecture

High-Level Overview

LearnPanta follows a durable, event-driven architecture. The core principle: every major AI operation is a persistent Temporal workflow that survives crashes and retries automatically.

Durable Workflows (Temporal)

Unlike standard CRUD apps, LearnPanta uses Temporal to manage exam session lifecycles:

Why Temporal?

  1. Automatic Retry: If a worker crashes or AI times out, Temporal retries without losing progress
  2. State Persistence: Exam state survives server restarts
  3. Long-Running: Handles 2-6+ hour exam sessions reliably

Session Lifecycle

Workflow Timeline

Workflow Interaction Patterns

Signals (fire-and-forget): Frontend pushes data to workflow

# Backend receives metric, signals workflow
await workflow_handle.signal("add_metric", metric_data)

Queries (request-response): Frontend requests current state

# Get current session state
state = await workflow_handle.query("get_state")

Activities (durable execution): Workflow calls external services

# Workflow triggers AI analysis
result = await workflow.execute_activity(
    telemetry_analyzer_agent,
    input_data,
    start_to_close_timeout=timedelta(minutes=5)
)

AI Interaction Pattern

Every AI call follows a structured pattern:

Data Persistence

Data TypeStoragePurpose
Users, Exams, Sessions, QuestionsPostgreSQL (Cloud SQL)Core relational data
Temporal Workflow HistoryPostgreSQL (Temporal DB)Durable workflow state
Session MetricsTimescaleDB + Temporal StateHistorical analytics + per-session telemetry
Question EmbeddingsPineconeSemantic search vectors

Database Schema

Key Tables:

TablePurpose
examsCertification catalog (584 exams)
papersExam instances/forms
sectionsLogical groupings within papers
questionsQuestion bank with domain, tags, options
section_questionsLinks questions to sections with ordering
sessionsCandidate attempts with responses, feedback
stimuliShared content (passages, images, case studies)
assetsUploaded files (scratchpad images)
enrollmentsCandidate-Exam subscriptions

Kubernetes Deployment

API Routes Summary

RoutePurpose
POST /sessionsCreate exam session, start Temporal workflow
POST /sessions/{id}/finalizeSubmit exam, trigger feedback synthesis
WS /ws/stream/{id}Real-time telemetry streaming
GET /academic/examsList available exams
GET /academic/papers/{id}Get paper with sections and questions
POST /debrief/orchestrateGenerate beat-synced review script
POST /debrief/briefPer-question paragraph (review sync)
POST /debrief/ttsText-to-speech for debrief audio
POST /curator/batch-curateBatch generate exam content

AI Debrief Flow


Temporal Workflow Flow

AI Review Tab Flow

Security

  • Auth: Firebase ID token (Authorization: Bearer <id_token>)
  • Guest Sessions: Short‑lived X-Guest-Token for diagnostics
  • CORS: Configured for production domains
  • Database: Private Cloud SQL with IAM auth
  • Secrets: Kubernetes secrets for credentials

Next Steps