How haritssr/haritssr works
<explanation>
1. Identify the project type and purpose
• This is a full-stack, content-rich Next.js website (v13+). It serves as a personal portfolio/blog/experiments site with a mix of static pages (SSG), server-rendered pages (SSR), client-side React interactivity, MDX-based content, and serverless API routes.
• Key features from README: Experiences, Experiments, Blog, Technology, Pure (design system), About.
2. Analyze the file structure
• “app/” directory: Next.js App Router pages (TypeScript/TSX), layouts, parallel routes, dynamic segments.
• “pages/” directory: legacy pages router for the /experiments section and API endpoints under “pages/api/”.
• “components/”: reusable React UI components and design system primitives.
• “content/”: .mdx files representing blog posts/content.
• “data/”: JSON/TS/JS files with structured data (ExperiencesData, ExperimentsData, TechStackData, comments, etc.).
• “context/”: React context providers.
• “utils/”: helper functions (TOC generator, word count, MDX transforms, data loaders).
• Config/build files: next.config.js, contentlayer.config.js, tailwind.config.js, postcss.config.js.
• Static/public assets: images, favicons, robots.txt, pdf, icons.
3. Examine the README for additional insights
• Shows logical site structure: haritssr.com → experiences, experiments, blog, technology, pure, about.
• No existing architecture diagram; we need to build one from structure.
4. How to create a system design diagram
a. Main components
• Client-side Browser (user agent)
• Next.js Server (handles SSR/SSG, serves routes)
• App Router (app/) and Pages Router (pages/)
• Contentlayer build process (ingests MDX + data files at build time)
• Static Content Store (content/ folder, public/)
• Serverless API Endpoints (pages/api/*)
• Data sources: local data files (data/*), MDX content,
optional external APIs (e.g., search or comments backend if used)
• React Component Library (components/, context/)
• Utility modules (utils/)
• Build & Deploy pipeline (pnpm, Vercel/Netlify)
b. Relationships and interactions
1. Build time: Contentlayer reads MDX+data → generates JSON/TS artifacts → Next.js pre-renders static pages.
2. Runtime:
- Browser requests a route → Next.js Server returns SSR or static HTML + JS.
- Client hydration: React components mount and fetch data if needed.
- In-page navigation via Next.js Link → client routing.
- API calls: components call /api/* endpoints to fetch comments or search.
- Data retrieval: serverless functions read local data files or call third-party APIs.
- Dynamic imports: parallel routes and experimental pages load on demand.
c. Architectural patterns and design principles
• Hybrid rendering: SSG for MDX blog posts, SSR for dynamic pages (e.g., experiences with Figma embeds), client-side for interactivity.
• File-based routing: automatic mapping of app/ pages and API routes.
• Component-driven UI: central design system in components/ and pure/.
• Context providers for shared state.
• Utility layer for cross-cutting concerns (TOC generation, word counting).
d. Relevant technologies and frameworks
• Next.js (App Router + Pages API)
• React and React Context
• Contentlayer for MDX content ingestion
• Tailwind CSS + PostCSS
• TypeScript and JavaScript data files
• Serverless Functions (Node.js)
• pnpm for package management
• Vercel/Netlify (implied) for deployment
5. Tailoring the diagram to this full-stack site
• Emphasize the separation:
• Frontend: Browser & React UI
• Render Server: Next.js handling SSR/SSG
• Data/Content: MDX files, JSON/TS data modules, public assets
• API Layer: /api endpoints as serverless functions
• Show how Contentlayer bridges content files → build artifacts → frontend.
• Highlight dual routers: App Router vs. Pages Router for experiments.
6. Diagram elements to include
• Components as boxes with clear labels (e.g., “Browser (User)”, “Next.js SSR/SSG Server”, “App Router”, “Pages Router”, “API Functions”, “Contentlayer Build”, “MDX & Data Files”, “Component Library”, “Utils”).
• Arrows for data flow:
• Build arrow: MDX/data → Contentlayer → Next.js build
• Request arrow: Browser → Next.js server → HTML/JS → Browser
• API call arrow: Browser/Server → /api endpoints → Data files
• Color/shape coding:
• Blue boxes for runtime servers (Next.js, API)
• Green boxes for static content (MDX, JSON, public assets)
• Orange boxes for build processes (Contentlayer)
• Grey boxes for utilities and component libraries
• Optionally group related boxes inside a “Next.js Project” boundary, and place “Build” vs. “Runtime” zones.
7. Final guidelines
• Be very detailed: include both build-time and runtime flows.
• Capture essential architecture: hybrid rendering, content ingestion, API layer, component library.
• Include labels, arrows, color coding, legends.
• Avoid overcrowding: use swimlanes or zones (“Build Process”, “Server Runtime”, “Client”).
• Ensure each directory’s responsibility is represented as a component or data source in the diagram.
</explanation>