How patelhitarth08/preppanda-next works
Project type and purpose
• This is a full‑stack Next.js web application for creating, administering, taking, and monitoring assessments (quizzes/tests) within user groups.
• It provides user authentication, group management, custom/given assessments, real‑time monitoring, and statistics dashboards.
File structure
• Top‑level folders:
– pages/ – Next.js pages (both UI routes and API routes under pages/api)
– components/ – React UI components (Assessment, Group, Monitor, Charts, Profile, Panda, etc.)
– models/ – Data models (assessment, question, group, user, and associated stats)
– utils/ – Helper functions (DB connection, SHA key generator)
– public/ – Static assets (fonts, images, JSON data)
– styles/ – Global CSS (Tailwind config, PostCSS)
• API routes follow RESTful patterns: /api/assessment, /api/question, /api/group, /api/stats, /api/user.
• Config/build: next.config.js, tsconfig.json, tailwind.config.ts, postcss.config.js, package.json.
Cross‑reference the README
• Confirms a Create‑Next‑App scaffold with Next.js pages and API routes.
a. Main components:
– Client/browser (React UI in pages/*.tsx plus components/)
– Next.js Server (server‑side Next.js engine and serverless functions for API routes)
– Authentication layer (NextAuth via pages/api/auth/[...nextauth].ts)
– Database (MongoDB or similar, connected via utils/connectDB.ts)
– Data models (collections for user, group, assessment, question, stats)
– External services (OAuth providers, if any; hosting on Vercel)
– Static assets hosting (public/ folder served by Next.js)
b. Relationships and data flows:
– User → Browser UI → Next.js page/API route
– API route → utils/connectDB → Database → models → returns JSON
– UI submits forms (create/join group, create assessment, answer questions) → API → DB
– Monitoring UI polls/subscribes to timer/events (via API)
– Stats UI queries aggregated stats endpoints under /api/stats
– Authentication flow: Browser ↔ NextAuth serverless endpoint ↔ external OAuth/DB
c. Architectural patterns/design principles:
– Serverless functions (Next.js API routes) encapsulating back‑end logic
– MVC‑ish separation: pages/views call service layer (API routes) which use models for DB
– Component‑based UI (React functional components + Tailwind CSS)
– RESTful endpoints for CRUD operations on assessments, questions, groups, stats
– Reusable utility modules for DB connection and security (generateSHAKey)
d. Key technologies/frameworks/libraries:
– Next.js (React framework with SSR/SSG and API routes)
– React + TypeScript for UI
– Tailwind CSS for styling
– next-auth for authentication
– Chart.js (via BarChart, DoughnutChart components)
– Mongoose or native MongoDB driver (implied by connectDB and models)
– Vercel (deployment platform)
Detailed capture of essential elements
• Break the backend into sub‑components:
– Auth API
– Assessment API
– Question API
– Group API
– Stats API
– Utility modules (DB connector, SHA generator)
• Models layer as part of the DB access subsystem.
• Config files and static assets as ancillary elements (bottom or side).
• Endpoint and major UI page is reflected to show full coverage.