|
1 | 1 | ---
|
2 | 2 | title: Greenify | Localized community-driven greenification/plantation solution with AI
|
3 |
| -description: Greenify is a mobile application designed to encourage and facilitate sustainable practices by analyzing live image and building community via Perplexity Sonar API. |
4 |
| -sidebar_position: 6 |
5 |
| -keywords: [image processing, community, maps, expo, react native, flask, Perplexity, sonar] |
| 3 | +description: A mobile application that analyzes photos and location data to suggest suitable plants and build sustainable communities using Perplexity Sonar API |
| 4 | +sidebar_position: 19 |
| 5 | +keywords: [greenify, plant recommendation, community, expo, react native, flask, perplexity, sonar, image analysis, sustainability] |
6 | 6 | ---
|
7 | 7 |
|
8 |
| -# Greenify |
9 | 8 |
|
10 |
| - |
| 9 | +**Greenify** is a mobile application designed to encourage sustainable practices by analyzing live images and building communities. Users capture photos of their space (balcony, roadside, basement, etc.) and Greenify automatically analyzes the image using Perplexity's Sonar API to suggest suitable plants for that location. The app also connects like-minded people in the locality to create communities for sustainable, economic, and social growth. |
11 | 10 |
|
12 |
| -The inspiration for Greenify stems from the growing need to address environmental challenges and promote sustainable living. With the rise of urbanization and technology, we wanted to create a platform that merges innovation with eco-consciousness. Greenify aims to empower individuals and communities to take actionable steps toward a greener future by leveraging technology to make sustainability accessible and engaging. |
| 11 | +<iframe |
| 12 | + className="w-full aspect-video rounded-xl" |
| 13 | + src="https://www.youtube.com/embed/IFP0EiHqd7Y" |
| 14 | + title="YouTube video player" |
| 15 | + frameBorder="0" |
| 16 | + allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" |
| 17 | + allowFullScreen |
| 18 | +></iframe> |
13 | 19 |
|
14 | 20 | ## Features
|
15 | 21 |
|
16 |
| -Greenify is a mobile application designed to encourage and facilitate sustainable practices. It provides users with tools and resources to: |
| 22 | +* **AI-Powered Plant Analysis** using image recognition and location data to suggest suitable plants |
| 23 | +* **Location-Based Recommendations** considering weather, sunlight, and environmental conditions |
| 24 | +* **Community Building** connecting users with similar plant interests and sustainable goals |
| 25 | +* **Cross-Platform Mobile App** built with Expo for iOS, Android, and web |
| 26 | +* **Real-time Weather Integration** for accurate plant suitability assessment |
| 27 | +* **Structured JSON Output** using Pydantic models for consistent data handling |
| 28 | +* **AR Model Support** for enhanced plant visualization |
17 | 29 |
|
18 |
| -- Participate in community-driven eco-friendly challenges and initiatives. |
19 |
| -- Access a curated library of tips, guides, and resources for sustainable living. |
20 |
| -- Connect with like-minded individuals through a community platform to share ideas and inspire action. |
21 |
| - |
22 |
| -The app is designed to be user-friendly, visually appealing, and impactful, making it easier for users to integrate sustainability into their daily lives. |
| 30 | +## Abstract Data Flow Diagram |
| 31 | + |
23 | 32 |
|
24 | 33 | ## Prerequisites
|
25 | 34 |
|
26 |
| -- NodeJS 20.19.4 or later |
27 |
| -- Python 3.10.0 or later |
28 |
| -- Perplexity API key for Sonar integration |
29 |
| -- Expo (SDK version 51 or later) ([Setup guide](https://docs.expo.dev/)) |
30 |
| -- Android SDK/studio set up for local build or simulator run ([Setup guide](https://developer.android.com/about/versions/14/setup-sdk)) |
31 |
| -- Xcode installed if using Mac and for simulator run ([Setup guide](https://developer.apple.com/documentation/safari-developer-tools/installing-xcode-and-simulators)) |
32 |
| -- An Android/iPhone device for image capture with camera |
| 35 | +* Node.js 20.19.4+ and npm |
| 36 | +* Python 3.10.0+ and pip |
| 37 | +* Expo CLI and SDK 51+ |
| 38 | +* Perplexity API key (Sonar Pro and Sonar Deep Research) |
| 39 | +* Android SDK/Studio or Xcode (for local builds) |
| 40 | +* Mobile device with camera for image capture |
33 | 41 |
|
34 | 42 | ## Installation
|
35 | 43 |
|
36 |
| -This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app). Also there is a ```/service``` folder in the root directory of the project which contains the Flask API for communicating between frontend and Perplexity API. |
37 |
| - |
38 |
| -1. Install dependencies |
39 |
| - |
40 |
| - ```bash |
41 |
| - npm install |
42 |
| - ``` |
43 |
| - |
44 |
| -2. Start the app |
45 |
| - |
46 |
| - ```bash |
47 |
| - npx expo start |
48 |
| - ``` |
49 |
| - |
50 |
| -In the output, you'll find options to open the app in a |
| 44 | +```bash |
| 45 | +# Clone the repository |
| 46 | +git clone https://github.com/deepjyotipaulhere/greenify.git |
| 47 | +cd greenify |
51 | 48 |
|
52 |
| -- [development build](https://docs.expo.dev/develop/development-builds/introduction/) |
53 |
| -- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/) |
54 |
| -- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/) |
55 |
| -- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo |
| 49 | +# Install frontend dependencies |
| 50 | +npm install |
56 | 51 |
|
57 |
| -3. In another terminal navigate to ```/service``` folder and install dependencies |
58 |
| -```bash |
| 52 | +# Install backend dependencies |
| 53 | +cd service |
59 | 54 | pip install -r requirements.txt
|
60 | 55 | ```
|
61 |
| -4. Set ```PPLX_API_KEY``` in ```.env``` file inside the ```/service``` folder (create ```.env``` file if doesn't exist) |
62 |
| -4. Run Flask app |
63 |
| -```bash |
64 |
| -python app.py |
65 |
| -``` |
66 |
| -5. To open app in mobile |
67 |
| -##### Option 1 |
68 |
| -* Install Expo Go app from Play Store or App Store |
69 |
| -* Scan the QR code shown in the terminal |
70 |
| - |
71 |
| -##### Option 2 |
72 |
| -Open web browser in your smartphone and navigate to the URL shown in the console. |
73 | 56 |
|
74 |
| -## Abstract Data Flow Diagram |
75 |
| - |
| 57 | +## Configuration |
76 | 58 |
|
| 59 | +Create `.env` file in the `service` directory: |
| 60 | +```ini |
| 61 | +PPLX_API_KEY=your_perplexity_api_key_here |
| 62 | +``` |
77 | 63 |
|
78 | 64 | ## Usage
|
79 | 65 |
|
80 |
| -After running the app in your own setup or through the hosted URL, the following steps can be followed: |
| 66 | +1. **Start Backend Service**: |
| 67 | + ```bash |
| 68 | + cd service |
| 69 | + python app.py |
| 70 | + ``` |
81 | 71 |
|
82 |
| -### First Step: Greenification |
| 72 | +2. **Start Frontend App**: |
| 73 | + ```bash |
| 74 | + npx expo start |
| 75 | + ``` |
83 | 76 |
|
84 |
| -| | | |
85 |
| -|------|-------------| |
86 |
| -|  | <ul><li>The user opens the app, which requests permission to capture a photo and access the user's location.</li><li>The user takes a photo of their space (e.g., a balcony), and the app automatically captures their coordinates (latitude, longitude, and altitude).</li><li>The image is sent to the Perplexity <code>sonar-pro</code> model to analyze the environment (e.g., balcony, roadside), sunlight exposure, and available space for plants.</li><li>The resulting analysis and user coordinates are sent to the Perplexity <code>sonar-deep-research</code> model to get real-time weather information, assess plant growth suitability, and receive up to five plant suggestions.</li><li>The API returns an analysis of which plants are suitable based on the location type, sunlight, and whether it's an indoor or outdoor space.</li><li>The API also provides a list of suitable plants based on sunlight and average weather conditions for the location.</li><li>Finally, the user can share these plant suggestions with other users in the same locality.</li></ul> | |
| 77 | +3. **Access the App**: |
| 78 | + - Install Expo Go app and scan QR code, or |
| 79 | + - Open web browser on mobile and navigate to the URL shown |
87 | 80 |
|
88 |
| -### Second Step: Community Building |
| 81 | +4. **Use the App**: |
| 82 | + - Grant camera and location permissions |
| 83 | + - Take a photo of your space (balcony, garden, etc.) |
| 84 | + - Receive AI-powered plant recommendations |
| 85 | + - Connect with nearby users for community building |
89 | 86 |
|
90 |
| -| | | |
91 |
| -|-------------|------| |
92 |
| -| <ul><li>The community screen displays nearby users and the plant suggestions they received from the photos they uploaded.</li><li>The user clicks the “Start Matching” button to get AI-suggested matches with other users based on similar interests, plant suggestions, and the potential for sharing resources.</li><li>The API suggests community groups for matched users based on shared interests and recommended plants.</li><li>Each community group shows the matched users and an explanation for why they were matched.</li><li>The app also explains how the community can positively impact the local ecosystem and promote economic growth.</li></ul> |  | |
| 87 | + | |
93 | 88 |
|
94 | 89 | ## Code Explanation
|
95 | 90 |
|
96 |
| -Greenify was built using the [Expo](https://expo.dev) framework, which allowed us to create a cross-platform application for Android, iOS, and the web. Key technologies and tools used include: |
97 |
| - |
98 |
| -- **Frontend**: React Native with Expo for building the user interface and ensuring a seamless user experience. |
99 |
| -- **Backend**: A Python-based service using Flask to handle data processing and API endpoints. |
100 |
| -- **Perplexity AI**: Using Perplexity AI's sonar-pro and sonar-deep-research models to classify image, plant suggestions based on image and coordinates by realtime research, creating a community by matching users of similar plant suggestions |
101 |
| -- **Design**: Using React Native UI Kitten for custom themes and assets, including fonts and icons, to create a visually cohesive and engaging interface. |
102 |
| -- **File-based routing**: Leveraging Expo's file-based routing system for intuitive navigation. |
103 |
| -- **Community features**: Implemented using React Native components and hooks for real-time interaction. |
104 |
| - |
105 |
| -** Pydantic models ** |
106 |
| -```python |
107 |
| -from pydantic import BaseModel, Field |
108 |
| - |
109 |
| - |
110 |
| -class Plant(BaseModel): |
111 |
| - name: str |
112 |
| - image: str = Field(description="Image URL of the plant") |
113 |
| - description: str = Field(description="Description of the plant") |
114 |
| - care_instructions: str = Field(description="Care instructions for the plant") |
115 |
| - care_tips: str = Field(description="Care tips for the plant") |
116 |
| - AR_model: str = Field(description="AR model URL for the plant") |
117 |
| - |
118 |
| - |
119 |
| -class Answer1(BaseModel): |
120 |
| - description: str |
121 |
| - |
122 |
| -class Answer2(BaseModel): |
123 |
| - plants: list[Plant] |
124 |
| - |
125 |
| - |
126 |
| -class Benefit(BaseModel): |
127 |
| - type: str = Field(description="Type of the environmental benefit") |
128 |
| - amount: str = Field(description="How much percentage of improvement") |
129 |
| - direction: bool = Field(description="True means increasing, False means decreasing") |
130 |
| - |
131 |
| - |
132 |
| -class Group(BaseModel): |
133 |
| - users: list[str] = Field( |
134 |
| - description="List at least 2 or more users with similar plant suggestions and how they can combine same job in term of place, activities and plantation" |
135 |
| - ) |
136 |
| - description: list[str] = Field( |
137 |
| - description="Short description of how these people match with each other" |
138 |
| - ) |
139 |
| - benefits: list[Benefit] = Field( |
140 |
| - description="How this combination helps benefit the environment with parameter, percentage value" |
141 |
| - ) |
142 |
| - |
143 |
| - |
144 |
| -class Community(BaseModel): |
145 |
| - match: list[Group] |
146 |
| -``` |
147 |
| - |
148 |
| -** Image Analysis and Insights about the captured image using sonar-pro and structured JSON output ** |
149 |
| -```python |
150 |
| -payload = { |
151 |
| - "model": "sonar-pro", |
152 |
| - "messages": [ |
153 |
| - { |
154 |
| - "role": "user", |
155 |
| - "content": [ |
156 |
| - { |
157 |
| - "type": "text", |
158 |
| - "text": f"Analyze this image and return short description of the place with respect to suitability of plant growth ", |
159 |
| - }, |
160 |
| - {"type": "image_url", "image_url": {"url": image}}, |
161 |
| - ], |
162 |
| - }, |
163 |
| - ], |
164 |
| - "stream": False, |
165 |
| - "response_format": { |
166 |
| - "type": "json_schema", |
167 |
| - "json_schema": {"schema": Answer1.model_json_schema()}, |
168 |
| - }, |
169 |
| -} |
170 |
| -``` |
171 |
| - |
172 |
| -** Matching people with similar plant suggestions and interests and create a matching community using sonar-deep-research ** |
173 |
| -```python |
174 |
| -payload_research = { |
175 |
| - "model": "sonar-deep-research", |
176 |
| - "messages": [ |
177 |
| - { |
178 |
| - "role": "system", |
179 |
| - "content": "You are a plant growth expert. You are given a description of a place where an user want to grow some plants. You are also given latitude, longitude and altitude of the user. Your task is to suggest at most 5 plant that can be grown by the user in that particular place according to average weather.", |
180 |
| - }, |
181 |
| - { |
182 |
| - "role": "user", |
183 |
| - "content": f"I am standing in a place having coordinates [{lat}, {lng}] and altitude {alt}]. The place can be described as follows: {answer1}" |
184 |
| - "Suggest at most five suitable plants that can be grown here.", |
185 |
| - }, |
186 |
| - ], |
187 |
| - "stream": False, |
188 |
| - "response_format": { |
189 |
| - "type": "json_schema", |
190 |
| - "json_schema": {"schema": Answer2.model_json_schema()}, |
191 |
| - }, |
192 |
| -} |
193 |
| -``` |
194 |
| - |
| 91 | +* **Frontend**: React Native with Expo for cross-platform mobile development |
| 92 | +* **Backend**: Python Flask API handling image processing and Perplexity API integration |
| 93 | +* **AI Integration**: Perplexity Sonar Pro for image analysis and Sonar Deep Research for plant recommendations |
| 94 | +* **Data Models**: Pydantic models for structured JSON output and data validation |
| 95 | +* **Image Processing**: Real-time image analysis with location-based context |
| 96 | +* **Community Features**: User matching based on plant suggestions and sustainable interests |
| 97 | +* **Weather Integration**: Real-time weather data for accurate plant suitability assessment |
195 | 98 |
|
196 | 99 | ## Links
|
197 | 100 |
|
198 | 101 | - [GitHub Repository](https://github.com/deepjyotipaulhere/greenify)
|
199 |
| -- [Live Demo](https://greenify.expo.app) |
200 |
| - |
201 |
| - |
202 |
| -- Youtube Demo |
203 |
| - |
204 |
| -[](https://www.youtube.com/watch?v=IFP0EiHqd7Y) |
| 102 | +- [Live Demo](https://greenify.expo.app) |
0 commit comments