How mrnk2107/procurewatch works
ProcureWatch is a simple full-stack, 3-tier web application:
• Frontend: React (Vite + TypeScript + Tailwind) renders dashboards/tables and calls APIs.
• Backend: FastAPI serves REST endpoints and orchestrates scraping + analytics.
• Data layer: SQLite (tenders.db) persists tender records (and is created/seeded on startup).
• User → SPA → REST API → DB
• Plus the data ingestion path: backend scrapes an external government portal, parses/cleans, and writes to SQLite, with sample-data fallback when scraping fails.
Backend (backend/)
• main.py: FastAPI app + API endpoints + startup behavior (creates DB, scrapes, loads).
• database.py: SQLite connection + CRUD/query helpers (data access layer).
• models.py: data models (likely Pydantic + schema mapping).
• scraper.py: integration with Central Public Procurement Portal via Requests + BeautifulSoup; parsing/cleaning logic; dedupe.
• analytics.py: aggregation/statistics queries (ministry/category/state/type distributions).
Frontend (frontend/)
• src/api.ts: Axios client (defines how SPA calls backend).
• src/pages/*: route-level screens (Dashboard, TenderExplorer, TenderDetail, ClosingSoon, Landing).
• src/components/*: UI building blocks (StatCard, TenderTable, Layout, Header).
• src/config.ts: environment-driven API base URL (e.g., VITE_API_URL).
Top-level
• requirements.txt: backend dependencies.
• start.sh, start.bat: local run scripts; implies “single-machine dev” deployment.
Goal: show *what talks to what*, including the external portal.
Nodes to include
• User (Browser)
• React SPA (Vite dev server / static hosting)
• FastAPI service (Uvicorn)
• SQLite database file (tenders.db)
• External website: Central Public Procurement Portal (eprocure.gov.in)
• Browser → React SPA (HTTP)
• React SPA → FastAPI (REST/JSON)
• FastAPI ↔ SQLite (SQL queries)
• FastAPI → eprocure.gov.in (HTTP GET for scraping)
• (Optional) FastAPI → “Sample Data Generator” (internal fallback path when scrape fails)
Goal: show internal layering and data flow.
Components
• main.py (API layer / routing + startup lifecycle)
• scraper.py (ingestion + parsing)
• database.py (repository/data access)
• analytics.py (read-only aggregations)
• models.py (schemas/entities)
Startup ingestion
• main.py (startup event) → scraper.py (fetch + parse) → database.py (insert/skip duplicates) → SQLite
Tender Explorer / list
• React /tenders call → main.py endpoint → database.py query (filters/pagination) → SQLite → JSON response
Tender detail
• React /tenders/{id} → main.py → database.py → SQLite
Closing soon
• React /tenders/closing-soon?days=N → main.py → database.py date-filter query → SQLite
Analytics
• React /analytics* → main.py → analytics.py → database.py/direct SQL → SQLite → aggregated JSON
Notable pattern to label
• A clean API layer → service/logic (scraper/analytics) → data access (database.py) → SQLite separation.
Goal: show routing + API client + major UI composition.
Components
• App.tsx (routes/layout)
• Pages:
• Dashboard.tsx (stats + charts)
• TenderExplorer.tsx (search/filter/pagination table)
• TenderDetail.tsx (single tender view)
• ClosingSoon.tsx (deadline buckets/urgency)
• Landing.tsx
• Shared components:
• Layout.tsx, Header.tsx
• StatCard.tsx, TenderTable.tsx
• api.ts (Axios wrapper)
• config.ts (API base URL / env)
Edges
• Pages → api.ts (fetch data)
• api.ts → FastAPI endpoints (REST)
• Pages → Components (composition)
Runtime (user-driven)
• Browser → React (UI navigation)
• React → FastAPI (GET /tenders, /tenders/{id}, /tenders/closing-soon, /analytics*, /distinct/*)
• FastAPI → SQLite (read-heavy queries)
Ingestion (backend-driven)
• FastAPI (startup) → External portal (HTTP scrape)
• FastAPI → SQLite (insert/update)
• If scrape fails: FastAPI → Sample data → SQLite
• “HTTP/JSON”
• “SQL”
• “HTTP GET + HTML parsing”
Important architectural patterns / principles present here
• 3-tier architecture (SPA ↔ API ↔ DB).
• Backend “ETL-lite”: scrape → parse/clean → persist.
• Read-optimized analytics: aggregation endpoints built on DB queries.
• Hackathon-ready single-node deployment: everything runs locally without orchestration.
Technologies to label on components (keep it factual & visible)
• React 18, TypeScript, Vite
• TailwindCSS
• Axios (API client)
• Recharts (visualization)
• React Router (page routing)
• Python 3.9+
• FastAPI + Uvicorn
• Requests + BeautifulSoup4 (scraping)
• SQLite (file DB)