How sbktckp/quero works
Purpose and Runtime
Quero is a multi-tenant NEET/JEE preparation platform for institutes: faculty manage question banks and mock tests; students join an institute, take tests, and review attempts; admins manage people and progress. It runs as a TanStack Start/React 19 application on Vite, deployed to Vercel, with Bun for development/package management. Entry/runtime points are src/start.ts, src/server.ts, and src/router.tsx.
Routing and Access Boundary
TanStack Router file-based routes separate public marketing/auth pages from authenticated product areas. The authenticated route shell establishes the protected application boundary, then routes users to student, institute, mentor, counseling, and administrative workflows. Key paths: src/routes/__root.tsx, src/routes/_authenticated/route.tsx, src/routes/_authenticated/institute-workspace.tsx.
Identity, Tenancy, and Authorization
Supabase Auth supplies identity; Supabase Postgres and RLS enforce data isolation. Institutes are top-level tenants with optional branch hierarchy; users have role-specific access, and students belong to one institute at a time. Sensitive cross-tenant actions are intended to pass through SECURITY DEFINER database functions rather than broad client-side table access. Relevant boundaries: src/integrations/supabase/auth-middleware.ts, src/lib/auth.tsx, supabase/migrations/20260811100000_institute_isolation_hardening.sql.
Institute Workspace and Membership
The institute workspace is the operational hub for onboarding/join approval, faculty administration, student roster visibility, and role-specific dashboards. Student join-code enrollment creates a pending relationship for institute-admin approval. Components and domain operations are centered in src/components/institute/institute-admin-dashboard.tsx, src/components/institute/institute-join-card.tsx, and src/lib/institute.ts.
Question Bank and Content Ingestion
Faculty/admins create questions in a shared taxonomy of subject, chapter, and topic. Content proceeds through draft, submitted, approved, or rejected review states; only approved content can enter usable tests. CSV/XLSX and PDF-oriented import UI feed import/domain logic that resolves taxonomy names, identifies duplicate stems, exposes unmatched data, and supports constrained undo. Key paths: src/components/institute/question-import.tsx, src/components/institute/faculty-csv-import.tsx, src/lib/faculty-import.ts.
Test Construction, Publication, and Attempts
The core pipeline is import → build → review → publish → student attempt → review. Test lifecycle transitions are draft, in progress, ready for review, published, and closed. Full NEET tests require four 45-question sections; database constraints prevent repeats and publish gating requires complete approved sections. The student-facing attempt and review routes consume the resulting assignments. Key paths: src/components/institute/test-workbench.tsx, src/lib/test-builder.ts, src/routes/_authenticated/test.$attemptId.tsx.
External Services and Auxiliary Domains
Supabase is the primary backend for database, Auth, RPC, and policy enforcement, accessed through browser/server clients and typed bindings. Razorpay supports billing/payment flows and receives a server webhook. OpenAI-compatible AI SDK features support administrative content generation; mentor and counseling domains are separate authenticated product modules. Key paths: src/integrations/supabase/client.ts, src/lib/razorpay.server.ts, src/routes/api/razorpay-webhook.ts.
Main entry points: client.ts Supabase backend · route.tsx Authenticated shell · router.tsx File-based router · institute-admin-dashboard.tsx Institute operations hub
Components 21
Application
TanStack Start React product runtime.
- Start/Vite runtime · Bun-managed TanStack Start application deployed to Vercel.
src/start.ts - Server entry
src/server.ts - File-based router
src/router.tsx - Public marketing and auth
src/routes/__root.tsx - Authenticated shell · Protects product routes and directs role-specific workflows.
src/routes/_authenticated/route.tsx
Institute Operations
Tenant membership, content, and testing workflows.
- Institute workspace route
src/routes/_authenticated/institute-workspace.tsx - Institute operations hub · Runs join approval, faculty administration, roster visibility, and role dashboards.
src/components/institute/institute-admin-dashboard.tsx - Join-code enrollment · Creates a pending student-institute relationship for admin approval.
src/components/institute/institute-join-card.tsx - Institute domain operations
src/lib/institute.ts - Question import UI · CSV/XLSX and PDF-oriented import surfaces.
src/components/institute/question-import.tsx - Faculty CSV import
src/components/institute/faculty-csv-import.tsx - Import resolution · Resolves taxonomy, duplicate stems, unmatched data, and constrained undo.
src/lib/faculty-import.ts - Test workbench · Builds, reviews, and publishes tests from approved questions.
src/components/institute/test-workbench.tsx - Test lifecycle rules · Applies section completeness and publication gates.
src/lib/test-builder.ts - Student attempt and review
src/routes/_authenticated/test.$attemptId.tsx
Backend Boundaries
Supabase-enforced identity, data, and tenant isolation.
- Supabase Auth middleware
src/integrations/supabase/auth-middleware.ts - Client auth context
src/lib/auth.tsx - Supabase backend · Primary backend for typed data access and policy enforcement.
src/integrations/supabase/client.ts - Tenant isolation policy · Restricts tenants and routes sensitive cross-tenant actions through database functions.
supabase/migrations/20260811100000_institute_isolation_hardening.sql
External Services
- Razorpay billing
src/lib/razorpay.server.ts - Payment webhook
src/routes/api/razorpay-webhook.ts
Connections 23
- Start/Vite runtime → Server entry: boots server
- Start/Vite runtime → File-based router: renders routes
- File-based router → Public marketing and auth: public area
- File-based router → Authenticated shell: protected area
- Authenticated shell → Institute workspace route: workspace access
- Authenticated shell → Student attempt and review: student assessment
- Authenticated shell → Supabase Auth middleware: validates identity
- Client auth context → Supabase backend: uses auth session
- Institute workspace route → Institute operations hub: hosts
- Institute operations hub → Join-code enrollment: approves enrollment
- Institute operations hub → Institute domain operations: uses
- Join-code enrollment → Institute domain operations: creates pending membership
- Institute domain operations → Supabase backend: persists tenant data
- Question import UI → Import resolution: submits imports
- Faculty CSV import → Import resolution: submits CSV
- Import resolution → Supabase backend: stores reviewed questions
- Test workbench → Test lifecycle rules: applies build rules
- Test lifecycle rules → Supabase backend: reads approved content
- Test lifecycle rules → Student attempt and review: publishes assignments
- Student attempt and review → Supabase backend: records attempts
- Supabase backend → Tenant isolation policy: enforces policies
- Payment webhook → Razorpay billing: receives events
- Payment webhook → Supabase backend: updates billing state