How ludanjubara/classroom works
Project Type and Purpose
• This is a full-stack web application built with Next.js (App Router + legacy Pages Router) for managing classrooms, students, teachers, subjects, and related entities.
• It exposes both RESTful API routes (under app/api and pages/api) and real-time Socket.IO endpoints (under pages/api/socket).
Main Components
A. Client (Browser / Next.js Front-End)
• Next.js App Router pages (under app/) use React Server Components and Client Components.
• Components and features (under components/ and features/) implement UI, fetch data, manage local state.
• State management via React Context (providers/) and Zustand stores (stores/).
B. Next.js Server
• API Layer:
– app/api/*: domain-driven REST endpoints (entity, auth, edgestore, statistics).
– pages/api/socket: real-time messaging via Socket.IO.
• Server-side logic: Prisma ORM (prisma/schema.prisma) connects to PostgreSQL (config/db.ts).
• Integration with external services:
– KindeAuth for authentication (app/api/auth).
– Edgestore for file storage (config/edgestore.ts, lib/edgestore-server.ts).
– OpenAI for insights and summaries (config/openai.ts).
– Custom statistics reporter (api/send-statistics.ts).
C. Database
• PostgreSQL (Prisma schema in prisma/schema.prisma).
D. External Services
• KindeAuth (OAuth / SSO).
• EdgeStore (file uploads & retrieval).
• OpenAI API (insight generation).
• Analytics/Statistics endpoint.
Relationships and Data Flows
• Browser → Next.js Server (HTTP): page navigation, data fetching via REST endpoints.
• Browser ↔ Socket.IO endpoint for chat messages (WebSocket).
• Next.js Server → Database (Prisma/SQL) for CRUD operations on classroom, user, message, etc.
• Next.js Server → Edgestore for file upload/download.
• Next.js Server → OpenAI for generating statistics or summaries.
• Next.js Server → Statistics service to send usage metrics.
Architectural Patterns & Design Principles
• Domain-driven folder structure: features/<domain> encapsulate API calls, hooks, components, types.
• Separation of concerns:
– UI (components/, views/)
– Business logic (features/)
– Data access (API routes, lib/, services/)
– State management (context/, stores/)
• Hybrid rendering: React Server Components (data‐fetching in app/) vs Client Components for interactivity.
• Serverless functions approach: each route file under app/api and pages/api is a discrete function.
Detailed Capture of Architecture
• How features modules (classrooms, community, notifications, etc.) plug into the API layer.
• Where server vs client code runs (Server Components, Client Components).
• Flow of user actions: e.g., “Teacher uploads assignment → app/api/edgestore upload route → Edgestore → returns URL → persisted in DB.”