How hoangdinhthien/v0-swimming-lms-demo works
Project type and purpose
• This is a full-stack, multi-tenant Learning Management System (LMS) built on Next.js 13 (app directory) and deployed on Vercel, with back-end logic exposed as serverless API endpoints under /api.
• It supports role-based access control (admin, manager, instructor, student), tenant selection, authentication, and resource data (courses, students, instructors, news, media, etc.).
File structure
• Top-level “api” directory: Contains TypeScript files (*.ts) for each REST endpoint (courses, students, instructors, login, tenants, etc.) plus utility modules (api-utils, auth-utils, role-utils). These are deployed as serverless functions.
• “app” directory: Next.js 13 route handlers and React server/client components, organized by feature (login, signup, tenant-selection, courses, chat, dashboard by role). Uses file-system routing (page.tsx, layout.tsx, loading.tsx).
• “components” & “hooks” & “utils”: Shared React components (UI primitives, layout, guards, providers), custom React hooks (useTenant, useUserRole, useToast), utility functions.
• Configuration / tooling: next.config.mjs, tsconfig.json, Tailwind config, PostCSS, Vercel deployment files.
• Documentation under docs/ for RBA and tenancy patterns.
README insights
• Project syncs with v0.dev chat interface, automatically pushes code to this repo, and deploys on Vercel.
• No in-repo database code—data persistence and auth likely provided by external services via the API layer.
a. Main components
• Client (browser/mobile)
• CDN / Edge Network (Vercel)
• Next.js App (React server & client components)
• Serverless API layer (TypeScript functions under /api)
• Authentication & Authorization service (e.g. JWT, role-guard)
• Multi-tenant management module
• External Services:
– Database or headless CMS (courses, users, enrollments)
– Storage/Media service
– Notification service (email/SMS)
– Real-time/chat backend (if chat is real-time)
b. Relationships & data flow
• Client → Vercel Edge → Next.js renders pages / hydrates React
• Client/server components call /api/* endpoints
• API layer performs auth-guard, tenant check, then reads/writes to external DB or services
• Role-guard in UI layer (components/role-guard.tsx) ensures correct dashboard features
c. Architectural patterns
• File-system routing (Next.js 13 app dir)
• Serverless micro-service endpoints (each API file is its own function)
• Multi-tenant context provided via TenantProvider / client-side hook
• Role-based access control implemented in both API (role-utils.ts) and UI (role-guard.tsx)
• Shared UI primitives and theming (components/ui, theme-provider)
d. Key technologies
• Next.js 13 (app router, server & client components)
• React, TypeScript
• Tailwind CSS
• Vercel (deployment, CDN, edge)
• v0.dev integration (auto-sync & backend services)
Essential details to capture
• Multi-tenant context injection path
• Auth & role guard checks at both UI and API boundaries
• File-system routing mapping (page.tsx → URL path)
• Shared component library intake by all pages
• Deployment flow: Git push → V0.dev sync → Vercel build → Edge/CDN