# niharrd/njack-new-website-2025-update architecture

> Architecture diagram of the GitHub repository niharrd/njack-new-website-2025-update, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/niharrd/njack-new-website-2025-update
- Repository: https://github.com/niharrd/njack-new-website-2025-update

## Overview

##### 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)

## Diagram (Mermaid)

```mermaid
graph TD
    %% External
    Browser["Client Browser"]:::external
    Vercel["Vercel Platform"]:::extService
    NotionAPI["Notion API"]:::extService

    %% Static Assets Layer
    subgraph "Static Asset Layer"
        direction TB
        CDN["CDN / Static Asset Server"]:::static
        StaticGames["Static “Games” Collection"]:::static
    end

    %% Next.js Server
    subgraph "Next.js Application Server" 
        direction TB
        NextConfig["Next.js Configuration (next.config.js)"]:::server
        PageEngine["Page Rendering Engine (src/pages/)"]:::frontend
        UIComponents["Reusable UI Components (src/components/)"]:::frontend
        Styles["Global & Module Styles (src/styles/)"]:::frontend

        subgraph "Custom Templates"
            direction TB
            CustomApp["Custom App Wrapper (_app.js)"]:::frontend
            CustomDoc["Custom Document Template (_document.js)"]:::frontend
        end

        subgraph "Dynamic Content Pages"
            direction TB
            PageId["[pageId].js"]:::frontend
            ReportPage["report/[id].js"]:::frontend
        end

        subgraph "Section Layouts"
            direction TB
            DeptLayout["departments/_layout.js"]:::frontend
            ResLayout["resources/_layout.js"]:::frontend
        end

        subgraph "Features"
            direction TB
            HackmatrixDir["Hackathon Submissions (pages/hackmatrix/)"]:::frontend
            HackmatrixSub["Submissions View (pages/hackmatrixsub/view.js)"]:::frontend
            CheatReportPage["Cheat Reporting Page (report-cheating.js)"]:::frontend
        end

        subgraph "API Route Handlers"
            direction TB
            APIHandlers["API Route Handlers (src/pages/api/)"]:::backend
            APISetReport["setCheatingReport"]:::backend
            APIGetReport["getCheatingReport"]:::backend
        end

        Middleware["Middleware Layer (lib/init-middleware.js)"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DataJSON["Local JSON Files (src/data/*.json)"]:::data
    end

    %% Connections
    Browser -->|"requests pages"| CDN
    CDN -->|"serves assets"| Browser

    Browser -->|"page request"| PageEngine
    PageEngine -->|"renders pages"| Browser

    Browser -->|"fetch /api/*"| APIHandlers
    APIHandlers --> Middleware
    Middleware -->|"reads/writes JSON"| DataJSON
    Middleware -->|"calls external"| NotionAPI
    APISetReport --> Middleware
    APIGetReport --> Middleware
    Browser --> CheatReportPage
    CheatReportPage --> APISetReport
    CheatReportPage --> APIGetReport

    PageEngine --> UIComponents
    PageEngine --> Styles
    PageEngine --> CustomApp
    PageEngine --> CustomDoc
    PageEngine --> PageId
    PageEngine --> ReportPage
    PageEngine --> DeptLayout
    PageEngine --> ResLayout
    PageEngine --> HackmatrixDir
    PageEngine --> HackmatrixSub

    Vercel --> NextConfig
    Vercel --> PageEngine
    Vercel --> APIHandlers
    Vercel --> StaticGames
    Vercel --> CDN

    %% Click Events
    click CDN "https://github.com/niharrd/njack-new-website-2025-update/tree/master/public/"
    click StaticGames "https://github.com/niharrd/njack-new-website-2025-update/tree/master/public/NSOC/Games/"
    click NextConfig "https://github.com/niharrd/njack-new-website-2025-update/blob/master/next.config.js"
    click PageEngine "https://github.com/niharrd/njack-new-website-2025-update/tree/master/src/pages/"
    click UIComponents "https://github.com/niharrd/njack-new-website-2025-update/tree/master/src/components/"
    click Styles "https://github.com/niharrd/njack-new-website-2025-update/tree/master/src/styles/"
    click Middleware "https://github.com/niharrd/njack-new-website-2025-update/blob/master/lib/init-middleware.js"
    click APIHandlers "https://github.com/niharrd/njack-new-website-2025-update/tree/master/src/pages/api/"
    click DataJSON "https://github.com/niharrd/njack-new-website-2025-update/tree/master/src/data/"
    click CustomApp "https://github.com/niharrd/njack-new-website-2025-update/blob/master/src/pages/_app.js"
    click CustomDoc "https://github.com/niharrd/njack-new-website-2025-update/blob/master/src/pages/_document.js"
    click PageId "https://github.com/niharrd/njack-new-website-2025-update/blob/master/src/pages/[pageId].js"
    click ReportPage "https://github.com/niharrd/njack-new-website-2025-update/blob/master/src/pages/report/[id].js"
    click DeptLayout "https://github.com/niharrd/njack-new-website-2025-update/blob/master/src/pages/departments/_layout.js"
    click ResLayout "https://github.com/niharrd/njack-new-website-2025-update/blob/master/src/pages/resources/_layout.js"
    click HackmatrixDir "https://github.com/niharrd/njack-new-website-2025-update/tree/master/src/pages/hackmatrix/"
    click HackmatrixSub "https://github.com/niharrd/njack-new-website-2025-update/blob/master/src/pages/hackmatrixsub/view.js"
    click CheatReportPage "https://github.com/niharrd/njack-new-website-2025-update/blob/master/src/pages/report-cheating.js"
    click APISetReport "https://github.com/niharrd/njack-new-website-2025-update/blob/master/src/pages/api/setCheatingReport.js"
    click APIGetReport "https://github.com/niharrd/njack-new-website-2025-update/blob/master/src/pages/api/getCheatingReport.js"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef static fill:#bbf,stroke:#333,stroke-width:1px
    classDef server fill:#bfb,stroke:#333,stroke-width:1px
    classDef frontend fill:#ffeb99,stroke:#333,stroke-width:1px
    classDef backend fill:#ffb3b3,stroke:#333,stroke-width:1px
    classDef data fill:#ffcc66,stroke:#333,stroke-width:1px
    classDef extService fill:#cceeff,stroke:#333,stroke-width:1px
```
