# therguy9201/dsa-search-engine architecture

> Architecture diagram of the GitHub repository therguy9201/dsa-search-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/therguy9201/dsa-search-engine
- Repository: https://github.com/therguy9201/dsa-search-engine

## Overview

1. **Overall shape**
   This repository is primarily a **frontend single-page application** for a DSA search/learning experience, with a smaller supporting layer for **data acquisition, static content generation, and serverless APIs**. The main runtime is the browser app in `src/`, built with **React + TypeScript + Vite** and styled with **Tailwind CSS**.

2. **UI / presentation layer**
   The app is organized around route-level pages in `src/pages/` such as `HomePage`, `AlgorithmsPage`, `AlgorithmDetailPage`, `ProblemsetPage`, `SearchPage`, `PlatformPage`, `SettingsPage`, and `SignInPage`. Shared layout and UI pieces live in `src/components/`, including navigation, hero/features/platform sections, user avatar/sign-in controls, and algorithm-specific content renderers.

3. **Routing and app bootstrap**
   `src/main.tsx` is the entry point that mounts the app, while `src/router.tsx` defines client-side navigation. This means the application is a **client-rendered routed app**, not a server-rendered site.

4. **Algorithm knowledge base**
   The algorithm catalog is embedded in the frontend source under `src/algorithms/`, with one folder per topic such as binary search, BFS, DFS, Dijkstra, hash table, heap sort, KMP, linked list, merge sort, and quick sort. Each topic has an `implementations.ts` file, and the UI pairs these with algorithm-detail components and topic-specific animations in `src/components/animations/`.

5. **Search and content composition**
   Search and discovery are handled through custom hooks like `useAlgorithmSearch`, while `AlgorithmContent`, `CodeImplementation`, and the various section components compose the detail pages. The `src/utils/algorithmUtils.ts` helper layer likely centralizes lookup/filtering logic so the search pages and detail pages can share the same catalog semantics.

6. **Problemset data as static assets**
   Problem lists for CodeChef, Codeforces, and LeetCode are stored as JSON in `public/data/`. These files are the frontend’s primary problem-source boundary: the browser reads them as static assets rather than querying a live database directly.

7. **Data-fetching and service boundary**
   `src/services/` contains the integration layer for all non-UI concerns: `problemsApi`, `problemStatsApi`, `api`, `googleAuthService`, and `activityTrackingService`. Custom hooks such as `useProblemset`, `useProblemStats`, `useProblemUserData`, and `useUserProfile` wrap those services so pages don’t talk to APIs directly.

8. **Authentication and user state**
   Google sign-in is integrated through `GoogleSignIn`, `AuthContext`, and `googleAuthService`. User identity then feeds UI features like the avatar component and any personalized problem/user data exposed through the hooks and service layer.

9. **Backend/support scripts**
   The `backend/` directory is not a traditional app server; it contains **scrapers and proxy utilities** used to build/update the static datasets. There are Python scrapers for CodeChef, Codeforces, and LeetCode, plus a `leetcode_api_proxy.js` helper for accessing LeetCode data. The `api/` directory contains lightweight serverless endpoints such as `codeforces-solved.js` and `leetcode-solved.js`, likely used to expose solved-count or profile-related data to the frontend.

10. **Automated content refresh pipeline**
   GitHub Actions in `.github/workflows/` automate data refreshes, especially for LeetCode and Codeforces. The intended flow is: scrape/update problem data → write JSON into `public/data/` → commit changes → deploy updated frontend. The repo also includes Vercel config and deployment-oriented files, so the static app and its generated datasets are designed to be rebuilt and redeployed automatically.

11. **Operational boundaries**
   The architecture cleanly separates:
   - **Browser UI** in `src/`
   - **Static knowledge/data** in `public/data/`
   - **Automation and scraping** in `backend/` and GitHub Actions
   - **Thin serverless integrations** in `api/`
   This makes the project mostly static at runtime, with freshness of problem data handled during build/automation rather than through a heavyweight backend.

Main entry points: [`src/pages`](https://github.com/therguy9201/dsa-search-engine/tree/main/src/pages) (Pages), [`src/services`](https://github.com/therguy9201/dsa-search-engine/tree/main/src/services) (Services), [`src/hooks`](https://github.com/therguy9201/dsa-search-engine/tree/main/src/hooks) (Data hooks), [`src/algorithms`](https://github.com/therguy9201/dsa-search-engine/tree/main/src/algorithms) (Catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend app"]
  node_main["Main<br/>app bootstrap<br/>[main.tsx]"]
  node_router["Router<br/>client routing<br/>[router.tsx]"]
  node_pages["Pages<br/>route views"]
  node_ui["Shared UI<br/>components"]
  node_auth(("Auth state<br/>context<br/>[AuthContext.tsx]"))
  node_hooks["Data hooks<br/>react hooks"]
  node_services["Services<br/>integration layer"]
end

subgraph group_catalog["Algorithm catalog"]
  node_algoutils["Algo utils<br/>lookup helpers<br/>[algorithmUtils.ts]"]
  node_algocatalog["Catalog<br/>topic modules"]
  node_renders["Detail renderers<br/>content components"]
  node_animations["Animations<br/>visualizations"]
end

subgraph group_data["Data sources"]
  node_problemsjson[("Problem data<br/>static json")]
  node_api["Serverless API<br/>edge endpoints"]
end

subgraph group_ops["Automation"]
  node_scrapers["Scrapers<br/>data acquisition"]
  node_workflows["CI workflows<br/>automation<br/>[workflows]"]
  node_deploy["Deploy config<br/>deployment<br/>[vercel.json]"]
end

node_main -->|"boots"| node_router
node_router -->|"navigates"| node_pages
node_pages -->|"composes"| node_ui
node_pages -->|"loads data"| node_hooks
node_hooks -->|"wraps"| node_services
node_services -->|"uses"| node_auth
node_ui -->|"shows user"| node_auth
node_pages -->|"reads"| node_algocatalog
node_algocatalog -->|"feeds"| node_renders
node_algocatalog -->|"drives"| node_animations
node_pages -->|"searches"| node_algoutils
node_hooks -->|"reads"| node_problemsjson
node_services -->|"fetches"| node_problemsjson
node_services -->|"calls"| node_api
node_scrapers -->|"updates"| node_problemsjson
node_workflows -->|"runs"| node_scrapers
node_workflows -->|"triggers"| node_deploy
node_deploy -->|"serves"| node_main

click node_main "https://github.com/therguy9201/dsa-search-engine/blob/main/src/main.tsx"
click node_router "https://github.com/therguy9201/dsa-search-engine/blob/main/src/router.tsx"
click node_pages "https://github.com/therguy9201/dsa-search-engine/tree/main/src/pages"
click node_ui "https://github.com/therguy9201/dsa-search-engine/tree/main/src/components"
click node_auth "https://github.com/therguy9201/dsa-search-engine/blob/main/src/context/AuthContext.tsx"
click node_hooks "https://github.com/therguy9201/dsa-search-engine/tree/main/src/hooks"
click node_services "https://github.com/therguy9201/dsa-search-engine/tree/main/src/services"
click node_algoutils "https://github.com/therguy9201/dsa-search-engine/blob/main/src/utils/algorithmUtils.ts"
click node_algocatalog "https://github.com/therguy9201/dsa-search-engine/tree/main/src/algorithms"
click node_renders "https://github.com/therguy9201/dsa-search-engine/blob/main/src/components/AlgorithmContent.tsx"
click node_animations "https://github.com/therguy9201/dsa-search-engine/tree/main/src/components/animations"
click node_problemsjson "https://github.com/therguy9201/dsa-search-engine/tree/main/public/data"
click node_api "https://github.com/therguy9201/dsa-search-engine/tree/main/api"
click node_scrapers "https://github.com/therguy9201/dsa-search-engine/tree/main/backend"
click node_workflows "https://github.com/therguy9201/dsa-search-engine/blob/main/.github/workflows"
click node_deploy "https://github.com/therguy9201/dsa-search-engine/blob/main/vercel.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_router,node_pages,node_ui,node_auth,node_hooks,node_services toneBlue
class node_algoutils,node_algocatalog,node_renders,node_animations toneAmber
class node_problemsjson,node_api toneMint
class node_scrapers,node_workflows,node_deploy toneRose
```

## Components

### Frontend app

Browser SPA built with React, TypeScript, and Vite.

- [Main](https://github.com/therguy9201/dsa-search-engine/blob/main/src/main.tsx): app bootstrap · Mounts the client app and starts the browser runtime. · `src/main.tsx`
- [Router](https://github.com/therguy9201/dsa-search-engine/blob/main/src/router.tsx): client routing · Defines page navigation for the SPA. · `src/router.tsx`
- [Pages](https://github.com/therguy9201/dsa-search-engine/tree/main/src/pages): route views · Home, search, algorithms, problemset, platform, settings, and sign-in screens. · `src/pages`
- [Shared UI](https://github.com/therguy9201/dsa-search-engine/tree/main/src/components): components · Navbar, hero/features sections, sidebar, avatar, sign-in, and page composition pieces. · `src/components`
- [Auth state](https://github.com/therguy9201/dsa-search-engine/blob/main/src/context/AuthContext.tsx): context · Google sign-in and user identity state shared across the app. · `src/context/AuthContext.tsx`
- [Data hooks](https://github.com/therguy9201/dsa-search-engine/tree/main/src/hooks): react hooks · Search, problemset, stats, and user-profile hooks that wrap services for pages. · `src/hooks`
- [Services](https://github.com/therguy9201/dsa-search-engine/tree/main/src/services): integration layer · API access, Google auth, problem stats, and activity tracking. · `src/services`

### Algorithm catalog

Embedded algorithm topics, renderers, and animations used by the detail pages.

- [Algo utils](https://github.com/therguy9201/dsa-search-engine/blob/main/src/utils/algorithmUtils.ts): lookup helpers · Shared algorithm catalog filtering and lookup logic. · `src/utils/algorithmUtils.ts`
- [Catalog](https://github.com/therguy9201/dsa-search-engine/tree/main/src/algorithms): topic modules · Embedded algorithm topics and implementations for search and detail views. · `src/algorithms`
- [Detail renderers](https://github.com/therguy9201/dsa-search-engine/blob/main/src/components/AlgorithmContent.tsx): content components · AlgorithmContent and CodeImplementation compose algorithm pages. · `src/components/AlgorithmContent.tsx`
- [Animations](https://github.com/therguy9201/dsa-search-engine/tree/main/src/components/animations): visualizations · Topic-specific algorithm animations used on detail pages. · `src/components/animations`

### Data sources

Static problem datasets and lightweight API boundary for solved/profile data.

- [Problem data](https://github.com/therguy9201/dsa-search-engine/tree/main/public/data): static json · CodeChef, Codeforces, and LeetCode problem lists served as frontend assets. · `public/data`
- [Serverless API](https://github.com/therguy9201/dsa-search-engine/tree/main/api): edge endpoints · Thin endpoints for solved-count or profile-related data. · `api`

### Automation

Scrapers and CI workflows that refresh datasets and deploy updates.

- [Scrapers](https://github.com/therguy9201/dsa-search-engine/tree/main/backend): data acquisition · Python and proxy utilities that build and refresh the problem datasets. · `backend`
- [CI workflows](https://github.com/therguy9201/dsa-search-engine/blob/main/.github/workflows): automation · GitHub Actions that update problem datasets and coordinate redeploys. · `.github/workflows`
- [Deploy config](https://github.com/therguy9201/dsa-search-engine/blob/main/vercel.json): deployment · Vercel and build configuration for the static app. · `vercel.json`

## Connections

- Main → Router: boots · Entry point mounts the routed SPA.
- Router → Pages: navigates · Client-side routes resolve to page views.
- Pages → Shared UI: composes · Pages assemble shared navigation and section components.
- Pages → Data hooks: loads data · Route views consume hooks instead of calling services directly.
- Data hooks → Services: wraps · Hooks centralize service usage and state shaping.
- Services → Auth state: uses · Google auth and user identity are managed through app state.
- Shared UI → Auth state: shows user · Avatar and sign-in controls reflect authentication state.
- Pages → Catalog: reads · Algorithm pages source embedded topic content.
- Catalog → Detail renderers: feeds · Catalog entries are rendered through reusable detail components.
- Catalog → Animations: drives · Topic modules pair with matching visual animations.
- Pages → Algo utils: searches · Search and listing views share catalog lookup logic.
- Data hooks → Problem data: reads · Problemset and stats flows consume static JSON datasets.
- Services → Problem data: fetches · Problem APIs operate on the dataset boundary exposed as static assets.
- Services → Serverless API: calls · Thin endpoints provide solved-count or profile-related data.
- Scrapers → Problem data: updates · Scrapers generate or refresh the JSON problem sources.
- CI workflows → Scrapers: runs · CI automates the data refresh pipeline.
- CI workflows → Deploy config: triggers · Automation supports rebuild and redeploy of the static app.
- Deploy config → Main: serves · Build config packages the SPA for deployment.
