How gitshanu/urban-roof-plantation works
Project Overview
• This is a full-stack web application built using Flask. Its primary purpose is to provide rooftop crop recommendations based on user inputs (area, water, sunlight) and offer an AI-powered chatbot for gardening questions.
• The key technologies include Flask (for backend handling), pandas (for data processing on crop_data.csv), Together AI (for the chatbot), and standard HTML/CSS/JavaScript (for the frontend interface). The application is deployed on Render.
Analyzing the File Structure
• At the top level you have important files such as README.md, app.py, crop_data.csv, and requirements.txt.
• The app.py file serves as the main entry point for the Flask application.
• The crop_data.csv file contains the dataset used for crop recommendation.
• The static directory includes necessary client-side assets (chat.js and style.css) that power the interactive parts of the application.
• The templates directory holds HTML files (index.html and result.html) that render the UI.
Elements
a. Main Components of the System:
• Frontend (Client Side): Represents the browser-based UI which loads HTML pages, applies CSS, and executes JavaScript (including the chat widget functionality).
• Backend Server (Flask Application): Handles HTTP routing, processes user inputs, performs crop filtering using pandas on the CSV data, and manages the endpoints related to both crop recommendation and the AI chatbot.
• Data Component: The crop_data.csv file, which is read and processed to generate recommendations.
• External Service: Together AI service which is used by the chatbot component for natural language processing and providing real-time responses.
• Deployment Environment: Render deployment (with Gunicorn) on which the application is hosted.
b. Relationships and Interactions:
• The user interacts with the frontend (via forms and chat widget) in the web browser.
• The frontend sends data (like form input for crop recommendation or chat input) through HTTP requests to the Flask backend.
• The Flask backend routes the requests appropriately: one route processes crop recommendations using pandas (reading crop_data.csv) and another route (/chat) forwards user queries to the Together AI API.
• The backend receives responses from the Together AI service and then sends back the responses to be displayed on the client.
• Static assets and HTML templates are served from their respective folders ensuring the UI renders correctly.
c. Architectural Patterns and Principles:
• MVC-like Structure: The separation between templates (view) and app.py (controller/logic) hints at a model-view-controller separation, even if it is simple and not formally structured.
• RESTful interactions: The communication between the frontend and backend using HTTP endpoints.
• External API Integration: Clear demarcation where the backend acts as a mediator between the client and the Together AI service.
d. Relevant Technologies and Their Roles:
• Flask: Core framework for handling HTTP requests and routing.
• pandas: Data processing library used for filtering crop recommendations.
• Together AI: External NLP service for powering the chatbot.
• HTML/CSS/JavaScript: Basic web technologies for the UI.
• Render (and Gunicorn): Deployment and production serving.
Emphasizing Detail
• Every component, even if small, is represented.