How piyush-ouch/rootify works
Project type and purpose
• Rootify is a full-stack web application (single-page/admin pages + backend proxy server) that empowers farmers and admins with agricultural insights.
• Key features include two roles (user/admin), a multimodal AI assistant for text/image queries, Firebase for auth and data storage, and a Node/Express proxy to the Google Generative AI (Gemini) API.
File structure
• Top-level “public” folder holds all static assets (HTML, CSS, JS, images).
• “server” folder contains the Node/Express proxy (app.js) plus package.json/lock.
• No monolithic framework: vanilla JS + Express, Firebase SDKs, and the @google/generative-ai SDK.
README insights
• Frontend communicates directly with Firebase Auth & Firestore via client SDKs.
• Backend server is used as a proxy to secure the Generative AI API key and forward chat/image requests to the Gemini API.
• Deployment can bundle static files and the Express app on platforms like Vercel, Netlify (Functions), or Firebase Hosting + Functions.
Main components & interactions
a. Components
• Static Hosting (e.g. Vercel/Netlify/Firebase Hosting)
• Frontend UI (public/index.html, user.html, admin.html + JS modules)
• Client-side Firebase SDKs (Auth & Firestore)
• Node.js/Express Proxy (“server/app.js”)
• Google Generative AI (Gemini) API
• Firebase Firestore Database
• Firebase Authentication Service
b. Relationships & Data Flow
1. Browser loads static assets from Hosting.
2. Frontend JS ↔ Firebase Auth (login/signup flows).
3. Authenticated Frontend JS ↔ Firestore (read/update soil/distributor data).
4. For AI queries: Frontend JS → Express Proxy → Gemini API → Proxy → Frontend.
c. Architectural patterns
• BFF (Backend-for-Frontend) via Node/Express proxy to secure AI API key.
• Client-side BaaS (Firebase) for authentication and real-time data.
• Separation of concerns: static UI vs. API proxy vs. data layer.
d. Technologies
• Frontend: HTML5, CSS3 (glassmorphism), ES6 modules.
• Backend: Node.js, Express.js, dotenv, @google/generative-ai.
• BaaS: Firebase Auth & Firestore.
• External AI: Google Gemini API.