# deathnet123/sparklers architecture

> Architecture diagram of the GitHub repository deathnet123/sparklers, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deathnet123/sparklers
- Repository: https://github.com/deathnet123/sparklers

## Overview

##### Project type and purpose
- This is a static/blog website built with Next.js (v13) that leverages Markdown/MDX content, custom layouts, and Tailwind CSS for styling. It’s intended as a personal cybersecurity blog (“Sparklers”) deployed (via Netlify) as a static site.

##### File structure
- Top-level directories:
- config/ – JSON data for menus, theme settings, social links
- content/ – Markdown/MDX articles and pages
- context/ – React context for global UI state (e.g., theme)
- hooks/ – Custom React hooks for window size, infinite-load, OS detection
- layouts/ – React components and templates (Base, Post, Partials, Shortcodes)
- lib/ – Build-time utilities (parsers, JSON generator, taxonomy, reading-time)
- pages/ – Next.js routing layer (including dynamic routes for posts, categories, pagination)
- public/ – Static assets (images, robots.txt, .htaccess)
- styles/ – Global SCSS and Tailwind config
- config files & scripts: next.config.js, postcss.config.js, tailwind.config.js, netlify.toml

##### Key insights from README
- Uses Next.js static SSG/SSG with live reload during development.
- Relies on Node/NPM scripts: `npm run dev`, `npm run build`.
- No backend API; all content is baked into static JSON + HTML at build time.

##### Main components
a. Developer Machine & CI/CD Pipeline
- Source Repo → Build step (Node.js, lib/* generators parse content/ + config/ → produce JSON + static pages) → Deploy to Netlify
b. Static Site Generation (SSG) Layer (Next.js)
- Input: content/*.mdx, config/*.json, layout templates → Next.js compiler → HTML, JSON, CSS, JS bundles
c. CDN/Hosting (Netlify)
- Hosts the output under public/; delivers assets via CDN
d. Client (Browser)
- Fetches index.html + JS bundles
- Hydrates React components
- Interactions: ThemeSwitcher (context), SearchModal (client-side JSON search), useLoadMore (fetch paginated JSON), share, newsletter form

##### Relationships & interactions
- Build Time: content & config feed into lib parsers → JSON generator → Next.js SSG → static files
- Runtime: Browser requests HTML & JS → React hydration → client-side routing (via next/router) & data fetching (from pre-generated JSON endpoints under /_next/data or public folder)
- External services: Netlify for hosting + CI/CD; third-party scripts for newsletter or analytics (if used)

##### Architectural patterns & principles
- Static Site Generation (SSG) for performance & SEO
- Component-based UI (layouts/components/partials/shortcodes)
- Unidirectional data flow: config → parsing → props → React UI
- Separation of concerns: content files vs. presentation (layouts) vs. data transforms (lib) vs. client logic (hooks & context)

##### Technologies & frameworks
- Next.js (Routing, SSG, Image, Data fetch), React (context, hooks), MDX/Markdown
- Tailwind CSS & SCSS, PostCSS
- Node.js build scripts, Netlify hosting

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Build Pipeline Layer
  subgraph "Build Pipeline"
    direction TB
    Source["Source Repo"]:::build
    Config["config/*.json"]:::build
    Content["content/*.mdx"]:::build
    CI["Node.js Build Tools"]:::build
    Parser["lib/contentParser.js"]:::build
    JSONGen["lib/jsonGenerator.js"]:::build

    Source --> CI
    Config --> CI
    Content --> CI
    CI --> Parser
    Parser --> JSONGen
  end

  %% SSG Layer
  subgraph "Static Site Generation (SSG)"
    direction TB
    NextBuild["Next.js SSG"]:::ssg
    Layouts["layouts/*"]:::ssg
    Pages["pages/*"]:::ssg
    Styles["styles/*"]:::ssg

    Config --> NextBuild
    Content --> NextBuild
    Parser --> NextBuild
    JSONGen --> NextBuild
    Layouts --> NextBuild
    Pages --> NextBuild
    Styles --> NextBuild
  end

  %% Hosting/CDN Layer
  subgraph "Hosting & CDN"
    direction TB
    Netlify["Netlify (CI/CD)"]:::hosting
    CDN["CDN"]:::hosting

    NextBuild --> Netlify
    Netlify --> CDN
  end

  %% Client Browser Layer
  subgraph "Client Browser"
    direction TB
    Browser["Browser"]:::client
    Hydrate["React Hydration"]:::client
    UI["UI Components"]:::client
    Theme["ThemeSwitcher"]:::client
    Search["SearchModal"]:::client
    LoadMore["useLoadMore Hook"]:::client
    Context["Context State"]:::client

    Browser -->|fetch HTML/CSS/JS| CDN
    Browser -->|hydrate React| Hydrate
    Hydrate --> UI
    UI --> Theme
    UI --> Search
    UI --> LoadMore
    UI --> Context
  end

  %% Click Events
  click Config "https://github.com/deathnet123/sparklers/blob/main/config/config.json"
  click Content "https://github.com/deathnet123/sparklers/blob/main/content/_index.md"
  click Parser "https://github.com/deathnet123/sparklers/blob/main/lib/contentParser.js"
  click JSONGen "https://github.com/deathnet123/sparklers/blob/main/lib/jsonGenerator.js"
  click NextBuild "https://github.com/deathnet123/sparklers/blob/main/next.config.js"
  click Layouts "https://github.com/deathnet123/sparklers/blob/main/layouts/Baseof.js"
  click Pages "https://github.com/deathnet123/sparklers/blob/main/pages/index.js"
  click Styles "https://github.com/deathnet123/sparklers/blob/main/styles/base.scss"
  click Netlify "https://github.com/deathnet123/sparklers/blob/main/netlify.toml"
  click Theme "https://github.com/deathnet123/sparklers/blob/main/layouts/components/ThemeSwitcher.js"
  click Search "https://github.com/deathnet123/sparklers/blob/main/layouts/partials/SearchModal.js"
  click LoadMore "https://github.com/deathnet123/sparklers/blob/main/hooks/useLoadMore.js"
  click Context "https://github.com/deathnet123/sparklers/blob/main/context/state.js"

  %% Styles
  classDef build fill:#cce5ff,stroke:#333,stroke-width:1px;
  classDef ssg fill:#d4edda,stroke:#333,stroke-width:1px;
  classDef hosting fill:#f0f0f0,stroke:#333,stroke-width:1px;
  classDef client fill:#fff3cd,stroke:#333,stroke-width:1px;
```
