How sandeepgarikapati/cleanindia works
Project Identification
• The project is a Next.js web application that leverages Gemini AI for waste classification. Users upload images of waste, which are analyzed to identify the waste type and estimate quantity. A verifier confirms the matching image of the collected waste and, upon validation, rewards the waste collector with points.
• Key features include AI-powered waste classification, user submissions, image verification, reward points, and an admin dashboard. The application emphasizes responsible waste disposal using modern web technologies such as Next.js, Tailwind CSS, TypeScript, Drizzle ORM, and PostgreSQL, with external integrations (Gemini AI, WEB3Auth, Google Maps API).
File Structure Analysis
• The top-level directories (like "app", "components", "hook", "lib", and "utils") indicate a separation of concerns:
• The "app" directory contains multiple pages/components such as "collect", "leaderboard", "report", "rewards", and "settings". These represent different views or routes in the Next.js application.
• The "components" directory includes shared UI components such as Header, Sidebar, and several smaller UI widgets (badge, button, dropdown-menu, input) that are likely used across multiple pages.
• The "hook" directory holds custom React hooks (e.g., useMediaQuerty.ts) which manage behavior or state across the application.
• The "utils" and "lib" directories include database configurations and utility functions, such as database actions (dbConfig, actions, schema) that integrate with Drizzle ORM and PostgreSQL.
• Configuration files like next.config.mjs, tailwind.config.ts, tsconfig.json, and drizzle.config.js indicate build and tooling configuration.
Identifying System Components
• Frontend (Web Client):
• Pages within the "app" directory: Home page, Collection, Leaderboard, Report, Rewards, and Settings.
• Shared UI components (Header, Sidebar, other UI widgets from the components/ui folder).
• Custom Hooks (e.g., useMediaQuerty) for enhanced interactivity or responsiveness.
• Backend & API Layer:
• Next.js Server-Side Rendering (SSR) and API endpoints that facilitate waste image processing, verification, and integration with Gemini AI.
• Integration with WEB3Auth for authentication.
• Database:
• PostgreSQL, which is managed using Drizzle ORM. The utility functions and schema definitions under "utils/db" illustrate database actions and interactions.
• External Services:
• Gemini AI API for waste classification analysis.
• Google Maps API for any location-based functionality.
• WEB3Auth for user authentication.
• Deployment:
• The Vercel deployment setup (as indicated by the README) which is the hosting platform for the application.
Architectural Patterns & Design Principles
• The project uses a modular design, with clear separation between UI components (in the "app" and "components" directories) and business logic (in "utils", "lib", and "hook").
• The use of Next.js implies a hybrid model, supporting both client-side and server-side components.
• Incorporation of external APIs and authentication services shows a clear integration pattern where external dependencies are encapsulated within defined interfaces.
• The use of Drizzle ORM and a dedicated database utils directory highlights a clear abstraction over database interactions.
Final Advice
• Be as detailed as possible: break down the application’s routes, UI components, and backend services.
• Do not hesitate to add sub-components where necessary, particularly for complex interactions with external services.
• Remember that the goal is to capture all essential architectural elements and data flows between components.