How therguy9201/dsa-search-engine works
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: pages Pages · services Services · hooks Data hooks · algorithms Catalog
Components 16
Frontend app
Browser SPA built with React, TypeScript, and Vite.
- Main · Mounts the client app and starts the browser runtime.
src/main.tsx - Router · Defines page navigation for the SPA.
src/router.tsx - Pages · Home, search, algorithms, problemset, platform, settings, and sign-in screens.
src/pages - Shared UI · Navbar, hero/features sections, sidebar, avatar, sign-in, and page composition pieces.
src/components - Auth state · Google sign-in and user identity state shared across the app.
src/context/AuthContext.tsx - Data hooks · Search, problemset, stats, and user-profile hooks that wrap services for pages.
src/hooks - Services · 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 · Shared algorithm catalog filtering and lookup logic.
src/utils/algorithmUtils.ts - Catalog · Embedded algorithm topics and implementations for search and detail views.
src/algorithms - Detail renderers · AlgorithmContent and CodeImplementation compose algorithm pages.
src/components/AlgorithmContent.tsx - Animations · 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 · CodeChef, Codeforces, and LeetCode problem lists served as frontend assets.
public/data - Serverless API · Thin endpoints for solved-count or profile-related data.
api
Automation
Scrapers and CI workflows that refresh datasets and deploy updates.
- Scrapers · Python and proxy utilities that build and refresh the problem datasets.
backend - CI workflows · GitHub Actions that update problem datasets and coordinate redeploys.
.github/workflows - Deploy config · Vercel and build configuration for the static app.
vercel.json
Connections 18
- 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.