How charliemeyer2000/website2 works
Project Type and Purpose
• This is a full-stack Next.js (pages router) blog/website, using SSG/SSR for content pages, MDX for authoring, serverless API routes for dynamic features (guestbook, view counts, XKCD fetch), and NextAuth for GitHub-based authentication.
Main Components
a. Client (Browser)
• React components under /components and page components under /pages.
• Uses SCSS modules for styling and Framer Motion for animations.
b. Next.js Server (Server-Side Rendering & Serverless Functions)
• Page rendering: getStaticProps / getStaticPaths pull MDX files from /posts and transform them via next-mdx-remote + remark-rehype.
• API layer under /pages/api:
• /api/auth/[...nextauth]: NextAuth.js handles GitHub OAuth flows.
• /api/dynamo/*: CRUD endpoints (addNote, getNotes, getViews, updateItem) that talk to DynamoDB via utils/config/dynamoConfig.js.
• /api/xkcd/today: fetches current XKCD strip.
c. Data Layer / External Services
• AWS DynamoDB: two tables, one for “slug”-based view counts, one for “note”-based guestbook entries.
• GitHub OAuth via NextAuth.js.
• External HTTP fetch to https://xkcd.com for the latest comic.
d. Static Assets & Build
• Build config: next.config.js, jsconfig.json, SCSS global styles in /styles.
• Hosted on Vercel (or another Node-capable host).
Relationships & Data Flows
• Page request → Next.js server → SSG/SSR → HTML + JS bundle → Browser.
• Client hook (useViews) → /api/dynamo/getViews → DynamoDB → response → UI.
• Client hook (useGuestbook) → /api/dynamo/addNote → DynamoDB → updated list.
• Authentication flow: Browser ↔ NextAuth endpoint ↔ GitHub OAuth provider.
• MDX rendering happens at build‐time (SSG), no runtime DB dependency for posts.
Architectural Patterns & Design Principles
• SSG/SSR hybrid using Next.js pages router.
• Client‐side state & data fetching via custom React hooks.
• Separation of concerns:
• /components: reusable UI pieces
• /pages: route definitions & data loading
• /utils: data configuration & hooks
• /public & /static: assets
• Serverless functions for microservices‐style API endpoints.
• MDX content pipeline integrated into Next.js build.