How sanyamjain-16/educationchatbot works
1. This repository is a full-stack chatbot platform for a coaching centre use case: a public marketing site, an authenticated admin dashboard, an embeddable chat widget, and server-side APIs for chat, knowledge ingestion, and billing.
2. The app is organized around file-based routing in src/routes, with a public area (index, login, signup, chat.$token, widget.js) and a protected dashboard area under src/routes/_authenticated. The protected routes cover chatbot management, analytics, billing, leads, onboarding, settings, and admin views.
3. The frontend is a React app styled with a component library pattern (src/components/ui) and assembled into higher-level sections like hero, pricing, testimonials, FAQ, stats, footer, and trust blocks. These are mostly presentation layers for the landing site and dashboard screens.
4. Interactive product features are split into reusable UI subsystems: chatbot builder/demo/widget, custom cursor, 3D background/hero scenes, neural network visuals, device showcase, energy timeline, and embed-snippet generation. These are mostly client-side experience layers rather than backend logic.
5. Animation and motion behavior is centralized in src/animations and a set of hooks like useLenis, useCursor, useMagnetic, useMousePosition, and useCountUp. This suggests a highly interactive marketing experience with smooth scrolling, pointer effects, and animated sections.
6. The backend surface is exposed through route handlers in src/routes/api. The key flows are:
- api/knowledge.$chatbotId.ingest for uploading or indexing knowledge into a chatbot,
- api/public/chat.$token for serving public chatbot conversations,
- api/webhooks/razorpay for payment events and subscription/billing updates.
7. Chat and retrieval logic are separated into src/lib/api/rag.server.ts and src/lib/api/faq-cache.server.ts. That indicates a retrieval-augmented generation flow: chatbot knowledge is ingested, cached/queried server-side, then used to answer public chat requests.
8. Authentication and persistence are centered on Supabase. The repo includes Supabase client/server helpers, auth middleware/attacher, generated types, and a supabase/migrations folder. This means auth, database schema, and likely row-level security are core architectural boundaries, not just incidental infrastructure.
9. Billing is a distinct subsystem backed by Razorpay, with server-side functions in src/lib/api/billing.functions.ts and a webhook handler. Billing likely gates premium chatbot or dashboard features, and the webhook is the source of truth for payment state changes.
10. Public access vs. authenticated access is an important boundary. Public users can interact with a chatbot via tokenized endpoints or embedded widget code, while authenticated staff manage chatbots, leads, analytics, and settings through the dashboard. The token-based chat route and widget script are the main distribution mechanisms for customer-facing chat.
11. Server/runtime entry points are src/server.ts and src/start.ts, with vite.config.ts and routeTree.gen.ts indicating a modern TypeScript web stack built around file-based routing and server-rendered/API-capable routes.
12. In an architecture diagram, the main boxes should be: marketing site/UI, authenticated dashboard UI, public chat widget, application server/routes, chatbot knowledge/RAG layer, Supabase auth/database, and Razorpay billing/webhooks. The primary data flow is: admin creates chatbot and uploads knowledge → server ingests/indexes data → public widget/chat hits tokenized chat endpoint → response is generated from stored knowledge → billing/auth updates flow through Supabase and Razorpay webhooks.
Main entry points: client.ts Supabase stack · router.tsx Root router · index.tsx Marketing site · dashboard.tsx Dashboard shell
Components 19
Frontend surfaces
Public marketing site, dashboard UI, and embeddable chat entrypoints.
- Marketing site · Public landing pages, onboarding entrypoints, and marketing content.
src/routes/index.tsx - Auth pages · Login and signup surfaces for account access.
src/routes/login.tsx - Dashboard shell · Authenticated dashboard layout and navigation for staff workflows.
src/routes/_authenticated/dashboard.tsx - Chatbot admin · Dashboard screens for creating, editing, and viewing chatbots.
src/routes/_authenticated/dashboard.chatbots.tsx - Ops views · Analytics, billing, leads, onboarding, settings, and admin screens.
src/routes/_authenticated/dashboard.analytics.tsx - Chat widget · Client-side embeddable widget and tokenized chat experience.
src/routes/widget[.]js.ts
Interactive UI layers
Client-side experience components and motion systems used across the product.
- Site sections · Hero, pricing, testimonials, FAQ, stats, trust, footer, and similar page sections.
src/components/hero/HeroContent.tsx - Product demos · Chatbot builder, demo, widget, embed snippets, and device/showcase experiences.
src/components/ChatbotBuilder.tsx - Motion system · Centralized animations, scroll behavior, pointer effects, and count-up/magnetic interactions.
src/animations/gsap.ts
Server routes
File-based routes and API handlers that serve pages and backend actions.
- Root router · Top-level route tree and router setup for file-based navigation.
src/router.tsx - Public chat API · Token-based public conversation endpoint used by the widget and chat page.
src/routes/api/public/chat.$token.ts - Ingest API · Knowledge upload and indexing endpoint for chatbot content ingestion.
src/routes/api/knowledge.$chatbotId.ingest.ts - Billing webhook · Razorpay webhook receiver for payment events and billing state changes.
src/routes/api/webhooks/razorpay.ts
Chat intelligence
Knowledge ingestion, retrieval, and public chat response generation.
- RAG engine · Server-side retrieval-augmented generation flow for answering chat requests.
src/lib/api/rag.server.ts - FAQ cache · Cached FAQ and knowledge lookup layer supporting chat responses.
src/lib/api/faq-cache.server.ts
Auth and data
Supabase-backed authentication, persistence, and schema migrations.
- Supabase stack · Supabase client/server helpers, auth middleware, generated types, and persistence boundary.
src/integrations/supabase/client.ts - Schema migrations · Supabase migration history defining schema, security, ownership, and vector search support.
supabase/migrations/20260616000200_vector_search_helper.sql
Billing
Razorpay payment and subscription update flow.
- Billing functions · Server-side billing helpers and subscription state coordination.
src/lib/api/billing.functions.ts
Runtime and bootstrap
Application startup and build-time routing/runtime setup.
- Server bootstrap · Application startup and server entry files for the Vite/TypeScript runtime.
src/server.ts
Connections 22
- Root router → Marketing site: routes to · Root router composes the public marketing routes.
- Root router → Auth pages: routes to · Root router composes auth entry pages.
- Root router → Dashboard shell: routes to · Root router mounts the authenticated dashboard subtree.
- Dashboard shell → Chatbot admin: contains · Dashboard shell frames chatbot management screens.
- Dashboard shell → Ops views: contains · Dashboard shell frames analytics, billing, leads, and settings views.
- Marketing site → Site sections: renders · Landing pages are assembled from reusable site sections.
- Marketing site → Product demos: showcases · Marketing pages surface demos and product experience blocks.
- Product demos → Chat widget: includes · Product UI includes the embeddable chatbot experience.
- Product demos → Motion system: animates with · Interactive product modules use shared motion behavior.
- Site sections → Motion system: animates with · Landing page sections use shared animation primitives.
- Chat widget → Public chat API: calls · Widget sends conversation traffic to the public chat endpoint.
- Public chat API → RAG engine: generates via · Public chat responses are produced through retrieval-augmented generation.
- Ingest API → RAG engine: feeds · Ingestion endpoint prepares content for the retrieval layer.
- RAG engine → FAQ cache: queries · RAG flow consults cached FAQ and knowledge results.
- Ingest API → Supabase stack: stores in · Ingested chatbot knowledge is persisted through Supabase.
- Public chat API → Supabase stack: reads from · Chat endpoint relies on persisted chatbot, token, and session data.
- Supabase stack → Schema migrations: defined by · Schema and security behavior are established by migrations.
- Billing webhook → Billing functions: updates · Webhook events are translated into billing state changes.
- Billing functions → Supabase stack: persists to · Billing state and subscription data are stored in Supabase.
- Billing webhook → Supabase stack: verifies state · Webhook processing depends on persisted customer and subscription records.
- Server bootstrap → Root router: starts · Server bootstrap launches the routed application.
- Server bootstrap → Supabase stack: initializes · Runtime bootstraps Supabase-backed auth and database access.