How marcoguzman211/eduhub works
Project Type and Purpose
• This is a full-stack web application built with the T3 Stack: Next.js for the front end (React/SSR/SSG), NextAuth.js for authentication, tRPC for type-safe RPC between client and server, and Drizzle (ORM) on top of a relational database.
• It’s scaffolded via create-t3-app to serve marketing pages, a dashboard section (with upload, profile, saved items), and a backend API exposing authentication and business logic.
File Structure
• Top-level config & scripts:
– next.config.js, tsconfig.json, drizzle.config.ts, start-database.sh
– package.json, eslint.config.js, prettier.config.js, .husky for Git hooks
• Public assets under public/
• Frontend “app router” pages under src/app:
– (marketing) catch-all for unauthenticated marketing site
– (app) for protected dashboard pages
– Shared components in src/app/_components and src/lib/components
• API layer under src/app/api (Next.js Route Handlers)
– auth/[...nextauth] for NextAuth.js
– trpc/[trpc] for tRPC HTTP handler
• Server logic in src/server:
– auth/ (NextAuth config)
– api/routers (tRPC routers: post, session)
– db/ (Drizzle schema & connection)
• tRPC client helpers under src/trpc
• Global CSS under src/styles
Key Architecture Insights from README
• Core technologies: Next.js (pages + API routes), NextAuth.js, Drizzle ORM, Tailwind CSS, tRPC.
• Designed for rapid bootstrapping with SSR/SSG, full-end-to-end typing, modular pages.
Main Components
• Browser / Client (React pages in Next.js)
• Next.js Server / Node.js Runtime
– SSR/SSG Rendering Engine
– API Routes:
• /api/auth/[...nextauth] (NextAuth)
• /api/trpc/[trpc] (tRPC entry point)
• tRPC Routers & Business Logic (session, post…)
• Auth Module (NextAuth config, providers, session callbacks)
• Database Layer (Drizzle ORM over PostgreSQL or MySQL)
• External Services (OAuth providers if any, e-mail, S3 for upload if integrated)
Relationships & Interactions
• The browser requests pages (marketing or dashboard).
• For SSR/SSG pages, Next.js server fetches data via:
– tRPC client calling /api/trpc → tRPC server routers → Drizzle queries → DB
– NextAuth session check via cookie + server session callback → DB
• Client-side React components use the tRPC React client for mutations & queries.
• Auth flows (login, callback) go through NextAuth’s API route, which reads/writes to the same database via Drizzle.
Architectural Patterns & Principles
• Monorepo-style single Next.js app combining frontend, API routes, server logic.
• “API-First” via tRPC: type-safe RPC calls instead of traditional REST.
• SSR/SSG mixing marketing (public) and protected (dashboard) routes.
• Modular CSS + Tailwind utility classes.
• Separation of concerns: src/app for UI, src/server for business logic, src/lib for shared components/utilities.
Step-by-Step
2. Two frontend areas: Marketing Pages vs. Dashboard Pages.
• SSR/SSG Engine
• /api/auth/[...nextauth] (NextAuth.js)
• /api/trpc/[trpc] (tRPC Handler)
6. External OAuth providers connecting to the Auth API route.