How 111maaz/tg_c_lens works
Project type and purpose
• This is a full-stack, serverless-style web application called “T-G Crime Lens.”
• Purpose: Provide interactive crime analytics for the Indian state of Telangana, combining official crime statistics (from CSV/GeoJSON) with an unofficial, rate-limited citizen reporting system, all administered via Supabase.
File structure
• Top-level artifacts:
• public/: static assets and data (CSV, districts.json, robots.txt)
• src/: all React/TypeScript code
• supabase/: database configuration & migrations (SQL)
• telangana_boundaries-master/: geo-boundary data package
• src/ substructure indicates:
• auth/: authentication UI, context, hooks (OAuth/JWT handled by Supabase Auth)
• components/: reusable UI (maps, charts, forms, modals)
• pages/: route-level components (dashboard, admin panels, error pages)
• integrations/supabase/: client setup and types for Supabase SDK
• services/: wrappers around Supabase queries (authService, crimeDataService, etc.)
• contexts/hooks/: global state (filters, toast notifications, data fetching hooks)
• Config/build scripts:
• vite.config.ts, tsconfig*.json, tailwind.config.ts for building with Vite, TS, TailwindCSS
• postcss.config.js, eslint.config.js
README for additional insights
• Frontend stack: React + TypeScript + Vite, UI via shadcn/ui + TailwindCSS
• Maps: Leaflet + MapLibre
• Backend entirely handled by Supabase (PostgreSQL + PostGIS for spatial data)
• Form validation: react-hook-form + Zod
• Data fetching & caching: TanStack Query
Elements
• Clear labels: “React App,” “Supabase Auth,” “PostgreSQL + PostGIS,” “Leaflet Map Layer,” “Admin Panel”
• From React App to Supabase endpoints (Auth, CRUD services)
• From Supabase DB to React App (data fetching)
• Rectangles for services/components (blue for frontend, green for backend, orange for DB)
• Clouds for external services (Supabase)
• Annotations for rate-limiting logic (5 reports/hour/IP) near the Unofficial Reports service
Final advice
• Be thorough: show each major React context, service layer, and Supabase module.
• Don’t overcomplicate: stick to discrete components (Frontend, Auth, DB, Map service, Admin).
• Iterate: validate with stakeholders or architects to ensure all flows are covered.