How lalithsha/post-wizards works
Project Type and Purpose
• This is a full-stack Next.js 13 application, using the App Router for both server-rendered and client-rendered pages.
• It implements authentication flows (sign-in, sign-up), a landing page, user dashboards, and saved-items views.
• It exposes two serverless API routes—/api/generator and /api/posts—and uses MongoDB as its data store.
File Structure
• src/app: App-router folders for auth ((auth)), landing ((landingPage)), dashboard, and saved views.
• src/components & src/components/ui: React UI components (Navbar, Sidebar, buttons, forms, etc.).
• src/contexts: React Context (DashboardContext) for client-side state.
• src/lib: mongodb.js handles DB connections, utils.js holds shared helper functions.
• src/models: Mongoose/Post model for the posts collection.
• src/utils: encryption and keys utilities, likely for token handling.
• middleware.ts: Global middleware (authentication guard, routing logic).
• Configuration: next.config.js, Tailwind, ESLint, PostCSS, jsconfig.json.
Core Architectural Components
a. Frontend (Next.js React App)
• Page layouts & nested routing (landing page, auth, dashboard, saved).
• UI components folder.
• React Context for client state sharing.
b. Backend / Serverless API
• /api/generator/route.js: Handles text/image generation requests.
• /api/posts/route.js: CRUD operations for posts.
• middleware.ts: Pre-request logic (auth checks, redirects).
c. Data Layer
• MongoDB Atlas (or self-hosted) cluster.
• lib/mongodb.js: Connection pooling.
• models/post.js: Schema definitions.
d. Utilities & Security
• Encryption utilities (src/utils/encryption.js) for sensitive data.
• Key management (src/utils/keys.js).
e. Deployment
• Vercel (serverless functions for API routes, automatic builds).
• Tailwind & PostCSS for styling pipeline.
Architectural Patterns
• File-based routing → map folders to route handlers.
• SSR & SSG (Next.js rendering strategies).
• Serverless functions for API layer.
• React Context for cross-page state.
• Separation of concerns: UI vs. data-access vs. middleware.