NeuralDash — Architecture Document
Describes the full architecture of a gamified learning platform for teens, covering frontend, backend, AI, and data model.
What this file does
Describes the full architecture of a gamified learning platform for teens, covering frontend, backend, AI, and data model.
When to use it
- Designing a Next.js app with server components and API routes
- Planning an AI tutor integration with safety filters
- Structuring a PostgreSQL schema with Prisma ORM
- Building a parent dashboard with consent and monitoring features
Assumes this stack
NeuralDash — Architecture Document
System Overview
Browser (Teen/Parent)
├── Next.js App (Vercel)
│ ├── App Router (Server Components default)
│ ├── Client Components (interactive: quiz, sandbox, tutor chat)
│ └── API Routes
│ ├── /api/auth/* (NextAuth.js)
│ ├── /api/tutor/* (AI Tutor with safety layer)
│ ├── /api/progress/* (XP, streaks, levels)
│ ├── /api/assessment/* (adaptive quiz engine)
│ └── /api/parent/* (parent dashboard data)
├── Prisma ORM → PostgreSQL (Neon)
├── Claude API (AI Tutor)
└── Pyodide (browser-side Python sandbox)
Tech Stack
| Layer | Technology | Why |
|---|---|---|
| Framework | Next.js 14 (App Router) | Server Components, Vercel deployment, API routes |
| Language | TypeScript (strict) | Type safety, developer experience |
| Styling | Tailwind CSS | Utility-first, dark theme, responsive |
| Components | shadcn/ui + custom GD components | Accessible base + game-inspired overlays |
| Database | PostgreSQL (Neon serverless) | Free tier, serverless, Prisma compatible |
| ORM | Prisma | Type-safe queries, migration management |
| Auth | NextAuth.js v5 | Google OAuth + credentials, session management |
| AI | Anthropic SDK (Claude API) | AI Tutor primary, abstraction layer for fallback |
| Python | Pyodide (WebAssembly) | Browser-native Python, no server execution |
| Testing | Vitest + Playwright | Unit + e2e coverage |
| Deploy | Vercel | Zero-config Next.js hosting |
Data Model (Core Entities)
User
id, username, email, hashedPassword, role (LEARNER|PARENT),
ageBracket, parentEmail, consentVerified, createdAt
LearnerProfile
id, userId, currentLevel (1-5), totalXP, currentStreak,
longestStreak, streakShieldAvailable, maturityScores (JSON),
placementLevel, onboardingCompleted
Module
id, level (1-5), order, title, theme, type (VIDEO|READING|CODING|QUIZ),
content (JSON), externalUrl, estimatedMinutes
Progress
id, learnerId, moduleId, status (NOT_STARTED|IN_PROGRESS|COMPLETED),
score, xpEarned, completedAt, timeSpentSeconds
Assessment
id, learnerId, level, type (PLACEMENT|LEVEL_UP),
questions (JSON), answers (JSON), score, passed, attemptNumber
TutorConversation
id, learnerId, moduleId, messages (JSON),
safetyFlags (JSON), createdAt
Badge
id, learnerId, type, name, description, awardedAt
Security Architecture
- Auth: NextAuth.js with JWT sessions, Google OAuth + credentials
- Consent Gate: Middleware checks consent status before content routes
- AI Safety: All Claude API responses pass through content filter before delivery
- Data: Username-only display, no PII in logs, GDPR/COPPA compliant
- Sandbox: Pyodide runs entirely in browser — no server code execution
API Routes
Auth
POST /api/auth/[...nextauth]— NextAuth handlersPOST /api/auth/consent— Parent consent verification
Learning
GET /api/modules?level={n}— Get modules for levelPOST /api/progress— Update module progressGET /api/dashboard— Dashboard data (level, XP, streak, next module)
AI Tutor
POST /api/tutor/chat— Send message, get AI responseGET /api/tutor/history?moduleId={id}— Get conversation history
Assessment
POST /api/assessment/start— Start assessmentPOST /api/assessment/answer— Submit answer, get next questionGET /api/assessment/result/{id}— Get assessment results
Gamification
GET /api/xp— Current XP and level progressGET /api/badges— Earned badgesGET /api/streak— Streak status
Parent
GET /api/parent/overview— Child progress summaryGET /api/parent/conversations— AI Tutor conversation logs
What's inside
System overview diagram, tech stack table, 7 core data entities, security architecture, and 6 API route groups.
Change this for your project
- Replace
NeuralDashwith your project name - Replace
devendranl/neuraldashwith your repository URL - Replace
Claude APIwith your chosen AI provider and model ID - Replace
Neonwith your PostgreSQL hosting provider
Where it goes
Save in docs/ or the repository root. Gives agents and new contributors a map of the codebase.
Worth borrowing
- Separating AI safety checks into a middleware layer before delivering responses
- Using Pyodide for browser-side Python execution to avoid server-side code risks
Related Documents
PCB Design Sources for Industry-Scale Testing
Lists GitHub repos and communities where you can download real PCB designs for testing optimization at scale.
Design Document: BharatSeva AI
Describes a 10-agent AWS system that helps India's informal workers access government schemes via voice-first, serverless architecture.
OpenClaw Enterprise Transformation Plan
Transforms a single-user AI agent into a dual-mode platform supporting both viral open-source and Fortune 500 enterprise deployments through phased security, IAM, audit, multi-tenancy, and Kubernetes features.
Qwen Image and Edit: Open-sourcing and Local GGUF Generations with Lightning
Documents the Qwen-Image and Qwen-Image-Edit models, covering architecture, training, benchmarks, ComfyUI setup, and prompting techniques for local GGUF deployment.