How roopsagar-k/questionpaperhub works
Project Type and Purpose
• This is a full-stack Next.js application (app directory uses the Next.js App Router), written in TypeScript.
• Purpose: allow users to upload or create question papers, extract text via an LLM, publish interactive posts, and take tests.
Main Components
a. Client / Frontend
• Next.js React pages & Server Components under app/ (e.g. /menu, /auth, /create-paper, /tests)
• UI library: ShadCN + Tailwind (components/ui)
• Context providers (UserContext, TestInfoContext)
b. API / Backend Layer
• Next.js API Routes under app/api/… grouped by resource: auth, register, posts, comments, votes, bookmarks, tests, tests-taken, upload, admin, search
• Each route implemented as a serverless function (e.g. route.ts)
c. Database
• PostgreSQL, accessed via Drizzle ORM (lib/drizzle/schema.ts, lib/drizzle/db.ts, migrations)
d. External Services
• Authentication: Auth.js (NextAuth)
• Cloudinary (image upload) via lib/cloudinary.ts
• LLM/Text extraction service (e.g. OpenAI) via lib/signin.ts or other utils
• PDF processing utilities (lib/pdfToImage.ts)
e. Static Assets & Config
• Public folder (animations, images)
• Config files: next.config.mjs, tailwind.config.ts, .env.example
Relationships & Data Flows
• User → Frontend: HTTP requests to Next.js pages (SSR/SSR) and client‐side interactions.
• Frontend → API: RESTful calls to /api/... endpoints for CRUD on posts, comments, tests, votes, bookmarks, file uploads.
• API → Database: Drizzle ORM executes SQL queries on PostgreSQL.
• API → External Services:
• Auth.js for session management
• Cloudinary for image uploads
• LLM endpoints for text extraction
• PDF utilities for local conversion
• Database → Frontend: via API, data serialized to JSON and rendered.
Architectural Patterns & Design Principles
• Monolithic serverless: All backend code lives in one Next.js project but is broken into discrete serverless routes.
• Componentized UI: small, reusable UI primitives (ShadCN) and feature components.
• Context-driven state: global contexts for user/session and test info.
• ORM layer abstraction: Drizzle provides type-safe DB access.
• Layered separation:
• Presentation (React/UI)
• Application/API (Next.js API routes)
• Persistence (Drizzle + Postgres)
• Infrastructure & services (Cloudinary, LLM, Auth)
a. Sketch the User Interface on the left:
• “Landing Page”, “Auth Pages”, “Home/Dashboard”, “Test Pages”, “Create Paper”
• Inside each, note key route.ts handlers
• “PostgreSQL via Drizzle ORM”
• Core tables: Users, Posts, Comments, Tests, TestAttempts, Bookmarks, Votes
d. On the far right, list External Services:
• Auth.js (OAuth / Session Store)
• Cloudinary (Image Storage)
• LLM API (Text Extraction)
• PDF Conversion Utility
• Frontend Auth pages → API/auth → Auth.js → Database
• Post creation UI → API/posts → Database, LLM
• File upload UI → API/upload → Cloudinary → Database
• Test-taking UI → API/tests-taken → Database