How tharanitharan-m/leettrack works
Project Type and Purpose
• LeetTrack is a full-stack, server-rendered Next.js application with client-side interactivity, designed as a DSA preparation platform.
• It exposes a React-driven UI, uses Next.js API Routes as its backend, leverages Firebase for auth and data storage, and integrates with an external AI service (Gemini) for code feedback.
File Structure Analysis
• Top-level folders:
• public/ – static assets (images, fonts).
• scripts/ – data‐migration and seeding scripts (Node.js/TypeScript).
• src/app/ – Next.js “App Router” pages and API Routes.
– api/feedback/route.ts – server endpoint for sending code to Gemini and storing feedback.
– login/, dashboard/, feedback/[submissionId]/ – page components.
• src/components/ – reusable UI building blocks (common, dashboard, layout, ui).
• src/contexts/ – React Contexts (AuthContext).
• src/lib/ – external service clients and utilities (firebase.ts, utils.ts).
• src/types/ – TypeScript type definitions.
• Configuration files for ESLint, Tailwind (postcss), tsconfig, Next.js, and environment variables indicate typical modern frontend tooling.
Key Architectural Points from README
• Client: Next.js with App Router & TailwindCSS.
• Authentication: Firebase Authentication (Google).
• Backend: Next.js API Routes (Node.js serverless functions) running on Vercel.
• Database: Firebase Firestore (NoSQL).
• AI: External Gemini 1.5 Pro API for code analysis.
Main Components and Their Interactions
a. User’s Browser (Client)
• Renders Next.js pages (React + SSR/ISR).
• Sends requests to Next.js API routes for data fetching or code submission.
b. Next.js Frontend (src/app, src/components)
• UI pages: Login, Dashboard, Feedback.
• Uses AuthContext to manage user session.
c. Next.js API Layer (src/app/api/feedback/route.ts)
• Verifies Firebase ID tokens.
• Reads/writes Firestore for problem tracking and user progress.
• For code feedback, forwards submissions to Gemini API, processes response, stores feedback.
d. Firebase Services
• Authentication: issues ID tokens on Google Sign-In.
• Firestore: stores users, problem metadata, submission history, streaks.
e. External AI Service (Gemini)
• Receives code and problem context, returns pattern insights and optimization suggestions.
f. Vercel Hosting & CI/CD
• Deploys both frontend and API routes as serverless functions.
g. Local Dev / Scripts
• scripts/seed-problems.ts: populates Firestore with problem data.
• scripts/migrate-problems.ts: transforms or updates existing problem definitions.
Architectural Patterns & Design Principles
• Separation of Concerns: clear split between UI components, domain logic (contexts, utils), and data services.
• Serverless Backend: each API Route acts as an independent function, scaling on demand.
• Micro-interactions: small reusable UI primitives in src/components/ui.
• Context-driven State: AuthContext provides user state throughout the app.
• Infrastructure as Code: scripts to automate Firestore seeding/migration.