How bigc7292/discount-hunter-ai works
Purpose and Deployable Surfaces
Discount Hunter AI is a React SaaS frontend for searching and presenting merchant discount-code results, with region selection, authentication, saved/recent results, and an operator-style console UI. A separate TypeScript backend supports discovery, verification, browser automation, proxying, and session handling.
Frontend bootstraps at src/index.tsx into src/App.tsx; backend process entry is backend/src/index.ts. The frontend is Vite-based and deployable through vercel.json; the backend includes Docker, Railway, and Procfile deployment artifacts in backend/Dockerfile, backend/railway.json, and backend/Procfile.
Frontend Application Shell
src/App.tsx owns the high-level application state and composition. It switches between landing, dashboard/workspace, auth, and pricing experiences using components such as src/components/LandingPage.tsx, src/components/Dashboard.tsx, and src/components/DashboardWorkspace.tsx.
The UI is a client-rendered React/TypeScript application, styled through src/index.css and Tailwind configuration. The landing/search path is centered on src/components/HeroSearchBar.tsx; authenticated or working sessions use the dashboard and sidebar surfaces.
Search and Result Workflow
A user supplies a merchant/query and optional region through src/components/HeroSearchBar.tsx and src/components/RegionSelector.tsx. Client service boundaries are concentrated in src/services/searchService.ts and src/services/apiService.ts, which should isolate UI components from provider/backend request details.
Results flow into display and selection components: src/components/ResultsDisplay.tsx, src/components/ResultCard.tsx, and src/components/CategoryChips.tsx. src/components/TerminalLog.tsx provides a visible progress/agent-log channel, likely reflecting discovery-stage status rather than being the discovery implementation itself.
Backend Discovery Pipeline
The backend’s architectural core is a provider-orchestrated discovery pipeline. backend/src/discovery/orchestrator.ts coordinates search/extraction stages, while backend/src/discovery.ts appears to provide a top-level discovery-facing module. Shared contracts are defined in backend/src/types.ts.
Provider adapters establish external-search boundaries: backend/src/discovery/serperService.ts, backend/src/discovery/tavilyService.ts, backend/src/discovery/firecrawlService.ts, backend/src/discovery/jinaService.ts, and backend/src/discovery/zernioService.ts. Extracted content is processed by backend/src/discovery/codeExtractor.ts, with region normalization/utilities in backend/src/discovery/regionUtils.ts.
Verification, Automation, and Network Controls
Discovered codes can pass through verification and automation capabilities in backend/src/verifier.ts and backend/src/browserBot.ts. These are distinct from discovery: discovery finds candidate sources/codes; verification/browser automation can test or inspect them.
Network/location-dependent requests are separated behind backend/src/proxyManager.ts and backend/src/geoProxy.ts. This boundary is material for provider access, regional commerce behavior, and avoiding proxy concerns leaking into UI or extraction logic.
Identity, Persistence, and External Services
Firebase is the frontend identity and datastore integration point, initialized in src/firebaseConfig.ts; repository-level firestore.rules and firestore.indexes.json define Firestore access/index infrastructure. Authentication UI is handled by src/components/AuthModal.tsx.
User/session and result-related backend state is represented by backend/src/sessionStore.ts and backend/src/profileManager.ts; frontend recent/saved-value access is isolated in src/services/recentSavingsService.ts. The repository also contains backend/src/newsletter.ts, indicating an outbound messaging/integration boundary.
README identifies Google Gemini and NVIDIA NIM as intelligence services, while the concrete frontend AI client present is src/services/nvidiaService.ts. API keys and service endpoints are environment-configured through .env.example and backend/.env.example.
Main entry points: apiService.ts Client API boundary · App.tsx Application shell · HeroSearchBar.tsx Landing search · index.ts Backend entry
Components 20
React Frontend
- Frontend bootstrap
src/index.tsx - Application shell · Selects landing, workspace, auth, and pricing experiences.
src/App.tsx - Landing search
src/components/HeroSearchBar.tsx - Region selector
src/components/RegionSelector.tsx - Dashboard workspace
src/components/DashboardWorkspace.tsx - Results presentation · Displays and filters returned discount candidates.
src/components/ResultsDisplay.tsx - Progress log · Visible discovery-stage progress channel.
src/components/TerminalLog.tsx - Client API boundary · Isolates UI from backend and provider request details.
src/services/apiService.ts - Saved and recent results
src/services/recentSavingsService.ts - Authentication UI
src/components/AuthModal.tsx - NVIDIA AI client
src/services/nvidiaService.ts
Backend Service
- Backend entry
backend/src/index.ts - Discovery module
backend/src/discovery.ts - Discovery orchestrator · Coordinates provider search and extraction stages.
backend/src/discovery/orchestrator.ts - Search provider adapters · Serper, Tavily, Firecrawl, Jina, and Zernio integrations.
backend/src/discovery/serperService.ts - Code extractor
backend/src/discovery/codeExtractor.ts - Verification and browser bot · Tests or inspects discovered codes independently of discovery.
backend/src/verifier.ts - Proxy and geo controls · Controls regional and provider-facing requests.
backend/src/proxyManager.ts
Identity & State
- Firebase integration · Frontend authentication and Firestore integration point.
src/firebaseConfig.ts - Session and profiles
backend/src/sessionStore.ts
Connections 21
- Frontend bootstrap → Application shell: mounts
- Application shell → Landing search: renders
- Application shell → Dashboard workspace: renders
- Application shell → Authentication UI: opens
- Landing search → Region selector: selects region
- Landing search → Client API boundary: submits query
- Client API boundary → Backend entry: calls
- Backend entry → Discovery module: serves
- Discovery module → Discovery orchestrator: starts
- Discovery orchestrator → Proxy and geo controls: uses regional access
- Discovery orchestrator → Search provider adapters: queries
- Search provider adapters → Code extractor: returns source content
- Code extractor → Verification and browser bot: passes candidate codes
- Client API boundary → Results presentation: supplies results
- Client API boundary → Progress log: supplies progress
- Results presentation → Saved and recent results: saves selections
- Authentication UI → Firebase integration: authenticates with
- Saved and recent results → Firebase integration: stores user data
- Backend entry → Session and profiles: manages
- Dashboard workspace → Results presentation: hosts
- Client API boundary → NVIDIA AI client: uses intelligence