How jasimedarath/edutech works
1. Overall shape
- This is a Next.js 14 App Router application with TypeScript and Tailwind, organized as a mobile-first EdTech PWA.
- The architecture splits into three main layers: route-based UI, server API routes, and shared service/integration libraries.
2. User-facing application shells
- The app/ directory defines distinct experiences for login/onboarding, student, teacher, admin, and super-admin users.
- Each role has its own route subtree and loading states, which suggests a role-based product surface rather than a single generic dashboard.
3. Role and access boundary
- middleware.ts and lib/auth.ts are the likely control points for authentication and authorization.
- Authentication is backed by Supabase Auth, with server/client helpers split across lib/supabase-server.ts and lib/supabase-browser.ts.
- The app likely redirects users into the correct role area after sign-in and blocks unauthorized access at the edge/server boundary.
4. Core domain areas
- Student flow: app/student/* and components like PracticeDeck, ChatTutor, BadgePill, and StudentNav support learning, practice, chat, and progress.
- Teacher flow: app/teacher/* plus GenerateForm, StudentDetailsSheet, HeatmapStrip, and TeacherNav support content generation and learner monitoring.
- Admin / super-admin flow: app/admin/* and app/super-admin/* manage tenants, schools, users, teachers, and admins.
5. API surface by domain
- The app/api/ tree is the main server-side boundary and is organized by feature:
- api/ai/* for content generation
- api/chat for tutoring/chat interactions
- api/progress/update for learner progress tracking
- api/teacher/* for teacher analytics and student data
- api/admin/* and api/super-admin/* for operational management
- api/notifications/* for push subscription and sending
- This indicates a feature-oriented API layer rather than a generic REST backend.
6. AI and content generation pipeline
- lib/claude.ts, lib/cloudflare.ts, and lib/zsky.ts show three AI/media providers:
- Anthropic Claude for text and quizzes
- Cloudflare Workers AI for images
- ZSky AI for video
- The AI routes are designed to gracefully fall back to demo responses when keys are missing, so the product can run in a partially configured or demo mode.
7. Persistence and backend services
- Supabase is the primary backend: auth, database, and likely storage.
- supabase/schema.sql is the canonical schema boundary, and the lib/*data.ts files imply domain-specific data access for tenants, teachers, and mock/demo content.
- lib/mock-data.ts suggests the UI can render without live backend data, which is useful for scaffolding and demos.
8. Offline-first PWA layer
- The project includes public/manifest.json, public/sw.js, Workbox assets, and lib/indexeddb.ts, so the app is built as a PWA with offline caching and local persistence.
- UI helpers like OfflineBanner, InstallPrompt, PullToRefresh, and PageLoader reinforce the mobile app-like experience.
- This means the client can continue to function with cached assets and local data, then sync back when online.
9. Notifications and device messaging
- lib/webpush.ts and app/api/notifications/* form the push notification subsystem.
- The app supports both subscription registration and server-side send flows, likely tied to classroom or learner engagement reminders.
10. Operational / admin management
- Admin routes manage schools, tenants, users, subjects, and classes, while super-admin routes manage admins, tenants, and school status.
- The presence of TenantProfileForm, TenantUsersManager, SchoolClassesManager, and SchoolSubjectsManager indicates a multi-tenant education administration model.
11. Runtime and deployment concerns
- This is a hybrid server/client Next.js app: pages render in the app router, while API routes handle server operations and external calls.
- lib/rate-limit.ts and lib/usage.ts indicate the backend includes quota/usage control, which is important for AI cost management and abuse prevention.
12. Diagram-friendly data flow
- A useful diagram would show:
- Browser/PWA client → Next.js app routes
- Auth via Supabase → role-based routing/middleware
- Client pages → internal API routes
- API routes → Supabase database/Auth + external AI providers + Web Push
- Offline path → Service worker + IndexedDB
- The main architectural boundary is between presentation/role surfaces and server integrations.
Main entry points: student Student app · layout.tsx App shell · middleware.ts Middleware · teacher Teacher app
Components 28
App surfaces
Route-based user experiences and shells
- App shell · Global layout and top-level routing entry for the App Router
app/layout.tsx - Login · Sign-in entry and loading state
app/login/page.tsx - Onboarding · First-run onboarding flow
app/onboarding/page.tsx - Student app · Student learning surface with practice, progress, topics, and chat
app/student - Teacher app · Teacher dashboard, generation, library, and student views
app/teacher - Admin app · Tenant and school administration surface
app/admin - Super-admin app · Platform-level management surface for tenants, schools, and admins
app/super-admin
API surface
Feature-oriented server routes
- AI API · Explanation, quiz, image, and video generation routes
app/api/ai - Chat API · Student tutoring chat endpoint
app/api/chat/route.ts - Progress API · Learner progress update endpoint
app/api/progress/update/route.ts - Teacher API · Teacher heatmap and student data endpoints
app/api/teacher - Admin API · Admin CRUD and school management endpoints
app/api/admin - Super-admin API · Platform management endpoints for admins, tenants, and schools
app/api/super-admin - Notifications API · Subscription registration and server-side send endpoints
app/api/notifications - Auth callback · Callback handler for login/session completion
app/auth/callback/route.ts
Shared services
Auth, data, AI, and infrastructure helpers
- Middleware · Edge authorization and role-based routing boundary
middleware.ts - Auth logic · Session and role helpers used for gating and redirects
lib/auth.ts - Server Supabase · Server-side Supabase integration for auth and data access
lib/supabase-server.ts - Browser Supabase · Client-side Supabase helper for browser sessions
lib/supabase-browser.ts - Teacher data · Teacher and classroom data access layer
lib/teacher-data.ts - Tenant data · Tenant and school administration data access layer
lib/tenant-data.ts - Claude · Anthropic-powered text, quiz, and explanation generation
lib/claude.ts - Cloudflare AI · Image generation provider integration
lib/cloudflare.ts - ZSky AI · Video generation provider integration
lib/zsky.ts - IndexedDB · Local persistence for offline-first client state
lib/indexeddb.ts - Web Push · Push subscription and delivery helpers
lib/webpush.ts - Schema · Canonical Supabase schema definition
supabase/schema.sql
PWA layer
Offline cache and installable client support
- PWA assets · Manifest, service worker, and Workbox assets for installable offline mode
public/sw.js
Connections 37
- Middleware → Auth logic: checks · Uses auth helpers to enforce role-based access
- Middleware → Student app: routes · Protects learner routes
- Middleware → Teacher app: routes · Protects teacher routes
- Middleware → Admin app: routes · Protects tenant admin routes
- Middleware → Super-admin app: routes · Protects platform admin routes
- Login → Auth callback: sign-in · Completes authentication flow
- App shell → Login: entry · Public entry path
- App shell → Onboarding: setup · First-time onboarding path
- App shell → Student app: surface · Learner experience shell
- App shell → Teacher app: surface · Teacher experience shell
- App shell → Admin app: surface · Admin experience shell
- App shell → Super-admin app: surface · Super-admin experience shell
- Student app → Chat API: uses · Student tutor chat
- Student app → Progress API: uses · Reports learning progress
- Student app → IndexedDB: caches · Stores offline student state
- Teacher app → Teacher API: uses · Loads class and learner analytics
- Teacher app → AI API: uses · Generates teaching content
- Admin app → Admin API: uses · Admin management actions
- Super-admin app → Super-admin API: uses · Platform management actions
- AI API → Claude: text · Explanation and quiz generation
- AI API → Cloudflare AI: image · Image generation
- AI API → ZSky AI: video · Video generation
- Chat API → Claude: tutor · Chat responses and tutoring assistance
- Progress API → Server Supabase: writes · Persists progress updates
- Teacher API → Teacher data: reads · Teacher dashboards and student summaries
- Admin API → Tenant data: reads/writes · Tenant, school, class, and user administration
- Super-admin API → Tenant data: reads/writes · Platform-level tenant and school management
- Notifications API → Web Push: sends · Push subscription and delivery
- Notifications API → Server Supabase: stores · Persists notification state and subscriptions
- Auth callback → Server Supabase: verifies · Completes server-side auth session setup
- Server Supabase → Schema: uses · Backed by canonical database schema
- Browser Supabase → Schema: uses · Client reads/writes through Supabase
- Student app → PWA assets: offline · Works with service worker and manifest
- Teacher app → PWA assets: offline · Works with service worker and manifest
- Admin app → PWA assets: offline · Works with service worker and manifest
- Super-admin app → PWA assets: offline · Works with service worker and manifest
- Student app → Notifications API: subscribes · Registers push subscription