Vishal.dev
Back
Full-Stack

KakshaOne — Open-Source School Management SaaS

Production multi-tenant school management platform — admissions, attendance, exams, results, homework, fee management with Razorpay, a super admin platform, 6 pricing tiers, and a 4-step school registration wizard. 107 API routes.

Next.js 15TypeScriptPostgreSQL 16Prisma 6NextAuth.js v4Tailwind CSS 4shadcn/uiRadix UIRazorpaySupabaseUpstash RedisjsPDFFramer Motion
107
API routes
378
Source files
6
Pricing tiers
4
User roles

Domain Knowledge

What problem this project solves

School operations involve deeply interconnected entities — students, fees, exams, attendance — that shift mid-year (transfers, promotions). KakshaOne models each school as a tenant with slug-based routing and query-level isolation, while feature-gating tiers control capacity. PDF generation (marksheets, certificates, fee slips, ID cards) is a first-class concern, not an afterthought.

Architecture

How the system is structured

A Next.js App Router application with 107 API route files organized by domain: auth, school management, student management, staff management, academics, attendance, fees & payments, financials, reports, and infrastructure (cron jobs, uploads, notifications). Three portals — admin, staff, student — plus a platform-level super admin and a registration wizard. Razorpay webhooks settle payments per school.

Data Model

Schema design and data flow

30+ Prisma models covering organizations (schools), users with 4 roles, students, staff, classes, subjects, timetables, exams, results, homework and submissions, study materials, certificates, ID cards, attendance, fee categories/structures/payments, expenses, and subscriptions.

Key Challenges

Hardest problems encountered

Fee management is the most complex module — installments, sibling discounts, late fees, scholarships, refunds, and reconciliation with Razorpay webhooks. Certificate and marksheet PDF generation had to handle print-quality layout. Multi-tenancy required every query to carry the school slug while keeping shared infrastructure.

Scaling Strategy

How the system grows

Shared infrastructure across schools with PostgreSQL connection pooling, Upstash Redis rate limiting and caching, Vercel cron jobs for fee reminders and student promotion, and background PDF generation to keep requests fast. Feature gates control per-plan limits on students, staff, and storage.

Security

Defense-in-depth approach

Four role levels (SUPER_ADMIN, ADMIN, STAFF, STUDENT), RBAC enforced at the API and data levels, query-level tenant isolation, Upstash brute-force protection, audit logging on all CRUD operations, and Zod schema validation throughout.

Failure Handling

Resilience and recovery

Razorpay webhooks are idempotent — duplicate callbacks never double-credit fees. Attendance saves are transactional and batch-rolled-back on partial failure. Report generation retries with backoff. Feature gates fall back safely for unknown tiers.

Observability

Monitoring and debugging

Admin dashboards for fee collection, attendance trends, exam results, and finance reports. Audit logs track record modifications. Cron job execution logs in Vercel. Structured logging with correlation across API calls.

Trade-offs

Engineering decisions and alternatives

Next.js API routes over a separate backend for deployment simplicity. Prisma over raw SQL for type safety. Razorpay over Stripe for the Indian market. Per-school Razorpay accounts over a central account for direct settlement. Feature-gated tiers over hardcoded plans.

Architecture Decisions

Key choices and what was rejected

Decision
Chosen
Rejected
Payments
Per-school Razorpay accounts
Central payment account
Tenancy
Slug routing + query isolation
Schema-per-tenant
Plans
Feature-gated tiers
Hardcoded plan logic
Onboarding
4-step registration wizard
Admin-provisioned schools

Senior-Level Topics

Concepts this project explores

Multi-Tenant SaaSRole-Based Access ControlPayment WebhooksFeature GatingPDF GenerationSubscription TiersBulk OperationsCron Automation