How wallyway/wikiud works
Project Type and Purpose
• This is a full-stack TypeScript Next.js application (Next.js 13 “app” directory structure) named “WikiUD.”
• It provides marketing pages (hero, pricing), an authentication flow (login), a user dashboard, and a set of JSON API routes (auth, seed, teachers) backed by a database.
File Structure Analysis
• Top-level “app” directory
• Divided into route groups: (marketing), (auth), (dashboard)
• Each group has its own layout.tsx and page.tsx components
• API routes under app/api:
– /auth/[...nextauth]/route.ts (NextAuth)
– /seed/route.ts (database seeding)
– /teachers/route.ts (teacher data CRUD)
• “components” directory
• Reusable UI components, design system primitives, theme provider
• “hooks” directory
• Custom React hooks for toasts, mounting, scroll lock
• “lib” directory
• Core utilities: auth.ts, db.ts (DB client), session.ts, string-utils, etc.
• services subfolder (lib/services):
– auth.service.ts
– teacher.service.ts
• validations and validators (user, username)
• Configuration and tooling
• next.config.js, tsconfig.json, tailwind.config.ts, PostCSS, ESLint, DevContainer, GitHub workflows
Key Architectural Patterns
• UI layer (React, Next.js app directory) separated from service layer (API routes + lib/services)
• Service layer abstracts data access and business logic in lib/services
• Authentication using NextAuth (app/api/auth) integrated with session management
• Database access via db.ts client, used by services and seed route
• CSS-in-JS via Tailwind + globals.css
Main Components
a. Browser / Client
• Marketing pages
• Auth pages
• Dashboard pages
• React components & hooks (components/, hooks/)
b. Next.js Server / Edge Functions (app directory)
• Routing & rendering engine
• API Routes (auth, seed, teachers)
c. Service Layer (lib/services)
• auth.service.ts
• teacher.service.ts
d. Database (db client in lib/db.ts, e.g., PostgreSQL or Mongo)
e. External Services
• OAuth providers via NextAuth (Google, GitHub, etc.)
f. Static Asset Store (public/)
Relationships and Data Flows
• Client → Next.js Server: HTTP GET/POST for pages (SSR/SSG) and API calls
• Next.js API Route → Service Layer (lib/services) → Database
• NextAuth API → External OAuth Providers & DB session store → Client session cookie
• Dashboard components call the /teachers API for CRUD operations via teacher.service → db
• Seed route populates initial data via lib/services
Essential Elements to Capture
• Clear labels for every major directory (“app”, “components”, “lib/services”)
• Explicit inclusion of lib/services per instructions