How error0x0000001/glolang works
Project type and purpose
• GloLang is a full-stack, Next.js 13 (App Router) web application for interactive language learning.
• It provides marketing pages, a “main” user area (courses, lessons, quests, shop, leaderboard), an admin console, and integrates with auth and payment services.
File structure (top-level components)
• app/
– (marketing): public marketing landing, header/footer layouts, static pages
– (main): authenticated user area—courses, learn, quests, shop, leaderboard
– admin: CRUD pages for challenges, courses, lessons, units
– api: Next.js serverless routes for challenges, courses, lessons, units, Stripe webhooks
– lesson: per-lesson UI components and layouts
• components/: shared React UI (modals, Sidebar, feed wrappers, ui library)
• actions/: server actions for challenge progress, user progress, subscriptions
• db/: Drizzle ORM setup, schema, and data queries
• lib/: wrappers for admin checks, Stripe SDK, utility functions
• store/: client state hooks (Zustand) for modal controls
• config/: environment‐driven configuration
• scripts/: database seed, reset, production build scripts
• middleware.ts: Clerk authentication enforcement
• next.config.mjs / drizzle.config.ts / tailwind.config.ts: build & styling configuration
README for additional insights
• Describes folder grouping, required environment variables including Clerk auth, Neon/PostgreSQL database, Stripe keys, and admin IDs.
a. Main components
1. Client (Browser / Mobile)
2. Next.js Application
– Frontend UI (React Server & Client Components in app/ and components/)
– API Layer (app/api/* serverless routes)
– Server Actions (actions/*)
– Middleware (Clerk auth checks)
3. Database (PostgreSQL via Drizzle ORM)
4. Authentication Service (Clerk)
5. Payment Service (Stripe + Webhooks)
6. Admin Console (Next.js admin pages)
b. Relationships and data flows
– Client → Next.js Frontend: HTTP(S) requests for SSR/SSG pages, client-side navigation
– Frontend → API Layer & Server Actions: fetch/update domain data (courses, lessons, progress)
– API Layer / Actions → Drizzle ORM → PostgreSQL: CRUD operations
– Middleware → Clerk: validate session, enforce protected routes
– Frontend & Server → Stripe SDK (lib/stripe.ts): create subscriptions, handle payments
– Stripe → Webhooks endpoint (app/api/webhooks/stripe/route.ts) → Actions → DB updates
c. Architectural patterns and principles
– Next.js App Router (layouts, nested routing, React Server Components)
– Server Actions for server-side logic collocated with UI
– Drizzle ORM for type-safe database access
– Middleware for cross-cutting concerns (auth enforcement)
– Zustand for lightweight client state management
– Separation of concerns: marketing vs. main app vs. admin
d. Key technologies and frameworks
– Next.js 13, React 18 (Server & Client Components)
– Drizzle ORM + PostgreSQL (Neon)
– Clerk (authentication)
– Stripe (billing & webhooks)
– Tailwind CSS
– TypeScript