How niharrd/njack-new-website-2025-update works
Project type and purpose
• This is a full-stack Next.js application (bootstrapped with create-next-app) that serves a public website with pages (React/SSR/SSG) and provides JSON data via API routes.
• It also hosts a large collection of static “Games” under public/NSOC/Games as standalone HTML/JS/CSS mini-apps.
File structure
• Top-level files: next.config.js, jsconfig.json, .gitignore, package.json, lib/init-middleware.js (utility for API route middleware).
• public/: static assets (images/fonts/audio) and NSOC/Games/* static game folders, plus root public HTML/CSS/JS.
• src/
• components/: reusable React UI components (Header, Footer, EventCard, etc.)
• data/: JSON files (events.json, coordinators.json, etc.) acting as a simple data layer.
• pages/:
– .js pages under src/pages deliver React pages (SSR/SSG)
– dynamic routes ([pageId].js, report/[id].js) for content pages
– /api/* files implement serverless functions (getEvents, getCoords, hackmatrix, setCheatingReport, etc.)
• styles/: CSS Modules and global styles.
• The structure implies an MVC-like split: React Views (pages+components), API/Controller layer (pages/api), Model layer (data/*.json), and static asset serving (public/).
Key insights from README
• Uses Yarn, Next.js.
• Next.js pages auto-update, API routes live under pages/api.
• Meant to deploy on Vercel (serverless functions).
a. Main components
• Client Browser
• CDN/Static Asset Server (serves public/* files and built .next/static)
• Next.js Application Server (hosted on Vercel/Node.js)
– Page Rendering Engine (SSR/SSG)
– API Route Handlers (serverless functions)
– Middleware layer (lib/init-middleware)
• Data Layer (JSON files in src/data or external Notion API via NotionPage)
• Third-party services (e.g., Notion API, Vercel Platform)
b. Relationships and interactions
1. Browser requests a page (e.g., /, /gallery, /departments/ml)
→ Routed to Next.js Page Rendering
→ Page may call getStaticProps/getServerSideProps
→ Those props functions read JSON from src/data or call internal API routes
→ Compiled HTML/JS sent back to Browser
2. Browser issues XHR/fetch to /api/getEvents or /api/setCheatingReport
→ Next.js serverless function invoked
→ init-middleware applies common middleware (CORS, body parsing)
→ Handler reads/writes JSON data or forwards to DB/Notion API
→ JSON response returned
3. Static files (images, fonts, mini-game HTML/JS/CSS under public/) served directly by CDN
4. Deployment via Vercel: build step compiles pages and API lambdas, outputs to .next folder and static assets to CDN
c. Architectural patterns/design principles
• Jamstack style: pre-rendered pages (SSG) and client hydration
• Serverless microservices: each API route as independent function
• Modular UI: React components + CSS Modules
• Layered approach: Presentation (components/pages), Data (JSON), API (serverless)
• Directory-based routing (Next.js convention)
d. Key technologies/frameworks/libraries
• Next.js (React, SSR/SSG, API routes)
• React (function components, hooks)
• Node.js (serverless functions)
• Yarn (package manager)
• CSS Modules & global CSS
• Vercel (hosting, deployment)