How jeancdevx/duolingo-clone works
Project type and purpose
• This is “Lingo,” a Duolingo-style full-stack web application built on Next.js’s App Router.
• It offers user authentication, course browsing and learning flows, admin CRUD pages, real-time progress tracking, payment/subscription via Stripe, and persistent storage in PostgreSQL.
File structure
• Top-level folders
• app/ – Next.js pages and API routes (App Router)
– (auth), (main), (marketing), admin UI under app/admin
– RESTful API subfolders under app/api
• components/ – React UI components, organized by feature
• db/ – Drizzle ORM config, schema, and queries
• lib/ – helper modules (admin enforcement, Stripe integration, utils)
• store/ – Zustand hooks for controlling modals
• scripts/ – data-seeding and production scripts
• public/ – static assets (SVGs, audio, images)
• middleware.ts – Next.js middleware (likely auth or routing)
• next.config.mjs, tailwind.config.ts, postcss.config.mjs – build and styling configs
• Key configuration:
• Clerk for auth (env keys)
• Stripe for payments (webhooks under app/api/webhooks/stripe)
• Neon/PostgreSQL via DATABASE_URL
• Drizzle ORM for type-safe DB access
Main components
a. Frontend (User-Facing)
• Next.js UI (app/(marketing), app/(auth), app/(main))
• React components (components/, pages under app/)
• Client-side state/hooks (store/)
b. Backend / Serverless
• Next.js API routes (app/api/*) deployed as serverless functions on Vercel
• Middleware (middleware.ts) for auth/session handling
c. Database
• PostgreSQL (Neon) accessed via Drizzle ORM (db/)
• Schema for users, courses, units, lessons, challenges, progress
d. External Services
• Clerk – user authentication & admin check (lib/admin.ts)
• Stripe – payment processing, webhook handler (lib/stripe.ts, app/api/webhooks/stripe)
e. Deployment Platform
• Vercel hosting for both frontend and serverless API
Relationships & data flows
• User → Next.js frontend (SSR/SSR + client-side hydration)
• Frontend ↔ API routes
• API routes → Drizzle ORM → PostgreSQL
• API routes → Stripe SDK → Stripe backend (create subscriptions, listen to webhooks)
• Middleware → Clerk APIs → enforce authentication/authorization
• Scripts (seed.ts, production.ts) → Drizzle → populate DB
Architectural patterns & design principles
• Monolithic Frontend/Backend in one Next.js repo using App Router
• “Feature folder” structure: grouping UI and logic by domain (courses, lessons, admin)
• Serverless functions for each API resource (RESTful endpoints)
• Middleware pattern for auth gating
• Type-safe DB access with Drizzle ORM
• Separation of concerns: UI (components/) vs data access (db/) vs business logic (lib/)