How bhaskarrijal/hashnode-blog works
Project Type and Purpose
• This is a monorepo containing a headless‑blog starter kit: three Next.js + Tailwind front‑end “themes” (enterprise, hashnode, personal) that consume Hashnode’s public GraphQL API. There is no bespoke backend or database in this repo; instead, the app fetches content at build‑time (SSG) or run‑time (SSR) from the external headless CMS (Hashnode).
File‑Structure Analysis
• Root: configuration files (.editorconfig, .gitignore, Dockerfile, pnpm‑workspace.yaml).
• packages/
• blog‑starter‑kit/themes/{enterprise, hashnode, personal}: each is a self‑contained Next.js app with:
– pages/ (SSG/SSR pages, dynamic [slug] routes, API routes for OG image generation)
– components/, lib/api (GraphQL queries/fragments/mutations), generated/ (GraphQL codegen outputs)
– public/, styles/, utils/
• eslint‑config‑custom, tsconfig, utils: shared ESLint rules, TypeScript presets, utility functions (feed generator, markdown renderer, SEO helpers).
README Insights
• Purpose: deployable to Vercel (or Cloudflare Worker proxy) under a subpath or root domain.
• Workflow: select one theme at import, supply env vars (GQL endpoint, publication host, base URL, mode).
• At build: Next.js codegen runs, SSG pulls from Hashnode’s GraphQL API.
• At run‐time: Next.js serverless functions handle OG‑image endpoints and dynamic requests.
a. Main Components
• Monorepo Workspace (root)
• Shared Packages (eslint‑config‑custom, tsconfig, utils)
• Selected Theme App (Next.js frontend)
• External Service: Hashnode GraphQL API
• CI/CD & Hosting Platform: Vercel (build system, static/CDN, serverless)
• Optional Proxy Layer: Cloudflare Worker (subpath routing)
• Developer & GitHub (source control trigger)
b. Relationships & Data Flows
1. Developer commits → pushes to GitHub → Vercel CI triggers.
2. Build Step on Vercel:
– pnpm install monorepo → runs GraphQL Codegen → Next.js build
– SSG: Next.js fetches content from Hashnode GraphQL endpoint via lib/api queries.
– Generates static HTML, JSON, and serverless functions for API/OG routes.
3. Deploy: static assets + serverless functions to Vercel’s Edge CDN.
4. User Requests:
– Static page: served from CDN edge.
– Dynamic page/SSR: Edge function fetches from GraphQL API at request time if not pre‑built.
– API/OG routes: serverless function generates Open Graph images.
5. (Optional) Cloudflare Worker intercepts subpath requests → proxies to Vercel deployment → others pass through to origin.
c. Architectural Patterns & Principles
– Monorepo with PNPM workspaces for sharing code/config across themes
– GraphQL Code Generation for type safety & query management
– Next.js: static site generation (SSG), incremental/deferred rendering, serverless API routes
– Headless CMS consumption: decoupling content management from presentation
– CDN + serverless functions for global low‑latency delivery
d. Key Technologies
– Next.js (React, Pages, API routes)
– TypeScript, GraphQL, codegen.yml
– Tailwind CSS, postcss
– pnpm workspaces
– Vercel (CI/CD, Edge CDN, Functions)
– Cloudflare Workers (optional proxy)