How vijaygupta18/system-design-simulator works
1. This repo is a browser-only Next.js 16 app that ships as a static client-side bundle. There is no backend, database, or API layer; all design state, content, simulation, and scoring run locally in React/TypeScript and persist in localStorage.
2. The application entry is the App Router under src/app/. It provides the global layout and styles, and the main page hosts a single rich workspace rather than multiple server-rendered routes. The repo also includes an Open Graph image generator for sharing.
3. The core UI shell is split into a few persistent regions: a left sidebar, a central ReactFlow-based canvas, a right analysis/control panel, and a top bar/interview bar. src/components/layout/ and src/components/sidebar/, src/components/panel/, and src/components/interview/ define those regions and the interactions between them.
4. The canvas subsystem in src/components/canvas/ is the main authoring surface. It renders component nodes, text nodes, animated edges, tab bars, and pen overlays/toolbar for annotation. This is where users drag infrastructure blocks, wire them together, and edit connection metadata like protocol and async/sync mode.
5. The application state is centralized in Zustand stores under src/store/. Separate stores handle the canvas graph, app-wide UI state, interview flow, simulation state, saved designs, custom problems/components, trade-offs, and pen input. hydration.ts and safeStorage.ts indicate the client-persistence boundary and prevent storage access issues during initial load.
6. The traffic simulation engine lives in src/engine/simulator.ts. It models request flow through the directed graph, including topological propagation, fan-in accumulation, traffic splitting, bottleneck effects, and cycle handling. This engine consumes the current canvas graph and produces per-node metrics used by the UI panel.
7. Scoring is a separate subsystem in src/scoring/. scorer.ts orchestrates a shared graph-derived evaluation, while rule modules under src/scoring/rules/ compute the five scoring dimensions: scalability, availability, latency, cost, and trade-offs. The important boundary here is that scoring is connectivity-aware: only wired components on the request path count.
8. Content is data-driven rather than hardcoded into the UI. src/data/ contains the component catalog, problem catalog, concept library, interview guides, learning path, and trade-off cards. These data files act as the domain model for what can be built, taught, scored, and loaded into the canvas as reference architectures.
9. Customization and interview workflows are first-class. Dialog components under src/components/dialogs/ cover create/load/save/confirm/support flows, and the interview components provide a timed multi-phase mock interview experience. The interview store and data modules coordinate the phase guidance, timer, and reference prompts.
10. The right panel is where simulation and evaluation become actionable. src/components/panel/ surfaces capacity calculations, metrics, score reports, simulation controls, trade-off logs, and comparison cards, all fed by store state and simulator/scorer outputs. This creates the feedback loop: build on the canvas, simulate traffic, inspect metrics, then revise.
11. Persistence and portability are emphasized throughout the architecture. Designs can be saved, loaded, exported, and re-opened locally; src/lib/exportCanvas.ts handles canvas export, and the README notes PNG/SVG/JSON export support. This makes the app suitable for offline interview prep with no account lifecycle.
12. Supporting utilities and UI primitives stay intentionally thin. src/components/ui/ contains shared base components, src/hooks/useBreakpoint.ts drives responsive behavior, and src/lib/ holds helper code such as icons, reference loading, and utilities. Styling uses Tailwind CSS v4 with shadcn-style primitives, while ReactFlow, Framer Motion, and perfect-freehand provide the interactive canvas and drawing experience.
Main entry points: app-shell.tsx App Shell · DesignCanvas.tsx Design Canvas · hydration.ts Persistence · RightPanel.tsx Right Panel
Components 24
App Shell
Next.js app router, global layout, and top-level page surface.
- Layout · Global app shell and styling entry.
src/app/layout.tsx - Workspace Page · Main single-screen client workspace.
src/app/page.tsx - OG Image · Open Graph image generator for sharing.
src/app/opengraph-image.tsx
Workspace UI
Persistent authoring, navigation, and feedback regions.
- Top Bar · Header controls and session navigation.
src/components/layout/top-bar.tsx - Sidebar · Left rail for problems, components, and learning.
src/components/sidebar/Sidebar.tsx - Right Panel · Simulation, metrics, and scoring feedback.
src/components/panel/RightPanel.tsx - Interview Bar · Timed interview phase control.
src/components/interview/InterviewBar.tsx - App Shell · Composes persistent regions into one workspace.
src/components/layout/app-shell.tsx
Canvas
ReactFlow-based design surface and annotation tools.
- Design Canvas · Main graph editor and canvas host.
src/components/canvas/DesignCanvas.tsx - Canvas Tools · Pen overlay and toolbar for markup.
src/components/canvas/PenToolbar.tsx - Edges · Animated connection rendering and edge types.
src/components/canvas/edges/AnimatedEdge.tsx - Nodes · Component and text node renderers.
src/components/canvas/nodes/ComponentNode.tsx - Tab Bar · Canvas tab navigation and mode switching.
src/components/canvas/CanvasTabBar.tsx
State
Zustand stores and persistence boundary.
- App Store · Global UI and layout state.
src/store/appStore.ts - Canvas Store · Authoring graph, nodes, edges, and metadata.
src/store/canvasStore.ts - Simulation Store · Traffic model inputs and results.
src/store/simulationStore.ts - Interview Store · Interview phases, timer, and prompts.
src/store/interviewStore.ts - Persistence · Hydration-safe client storage boundary.
src/store/hydration.ts
Core Logic
Simulation, scoring, and domain data.
- Simulator · Propagates requests through the directed graph.
src/engine/simulator.ts - Scorer · Coordinates graph-derived scoring.
src/scoring/scorer.ts - Domain Data · Components, problems, concepts, interview guides, and cards.
src/data/components.ts
Shared UI
Reusable primitives and dialogs.
- Export · Canvas export and portability helpers.
src/lib/exportCanvas.ts - Dialogs · Create, load, save, confirm, and support dialogs.
src/components/dialogs/SaveDialog.tsx - UI Primitives · Reusable buttons, tabs, sliders, tooltips, and toast.
src/components/ui/button.tsx
Connections 31
- Layout → Workspace Page: renders · Root layout mounts the main page.
- Workspace Page → App Shell: uses · Page delegates composition to the shell.
- App Shell → Top Bar: contains · Shell includes the top bar.
- App Shell → Sidebar: contains · Shell includes the left sidebar.
- App Shell → Design Canvas: contains · Shell anchors the central workspace.
- App Shell → Right Panel: contains · Shell includes the analysis panel.
- App Shell → Interview Bar: contains · Shell includes interview workflow controls.
- Design Canvas → Nodes: renders · Canvas uses node renderers for graph entities.
- Design Canvas → Edges: renders · Canvas uses custom edge rendering.
- Design Canvas → Tab Bar: hosts · Canvas exposes tabbed modes and views.
- Design Canvas → Canvas Tools: overlays · Annotation tools sit on top of the canvas.
- Sidebar → Domain Data: loads · Sidebar presents problems, components, and learning content.
- Right Panel → Simulation Store: reads · Panel displays simulation outputs.
- Right Panel → Scorer: reads · Panel shows scoring results and trade-offs.
- Simulation Store → Simulator: drives · Simulation state feeds the engine.
- Canvas Store → Simulator: provides graph · Current canvas graph is the simulation input.
- Canvas Store → Scorer: provides graph · Scoring evaluates the current wired design.
- Scorer → Right Panel: reports · Score summaries surface in the UI.
- Simulator → Right Panel: reports · Per-node metrics surface in the UI.
- Interview Store → Interview Bar: drives · Interview state controls the bar.
- App Store → App Shell: controls · Global UI state affects shell behavior.
- Persistence → App Store: hydrates · Client-safe storage initializes UI state.
- Persistence → Canvas Store: hydrates · Saved designs restore the graph.
- Persistence → Simulation Store: hydrates · Simulation settings and results persist locally.
- Persistence → Interview Store: hydrates · Interview progress persists locally.
- Dialogs → Persistence: writes · Save/load/create flows update local storage.
- Export → Canvas Store: exports · Canvas state can be exported as portable artifacts.
- Domain Data → Sidebar: feeds · Catalogs populate selection and learning UI.
- Domain Data → Scorer: defines criteria · Scoring references catalog-driven problem context.
- UI Primitives → Dialogs: builds · Dialogs are assembled from shared controls.
- UI Primitives → Top Bar: builds · Header controls reuse primitives.