Greenery is a comprehensive digital platform designed for plant enthusiasts, gardeners, and anyone passionate about sustainable living. This full-stack web application serves as a social network, educational resource, and digital toolkit for all aspects of gardening and plant care.
Built with modern web technologies including Next.js for seamless user experience and PostgreSQL for robust data management, Greenery integrates multiple APIs and AI-powered features to create an immersive gardening ecosystem.
π Watch the Full Project Demo
See Greenery in action! This comprehensive video demonstration showcases all the key features including the AI plant identification, community interactions, weather-based gardening calendar, marketplace functionality, and more.
- Framework: Next.js 14.2.5 (React-based full-stack framework)
- Styling: Tailwind CSS 3.4.1 with custom animations
- Authentication: Cookie-based session management with
js-cookie - Image Handling: Cloudinary integration for media storage
- Database: PostgreSQL with SSL configuration
- ORM: Native PostgreSQL client (
pg) - Environment Management: dotenv for configuration
- Plant Identification: Pl@ntNet API for AI-powered plant recognition
- AI Assistant: Google Gemini API for intelligent gardening advice
- Weather Data: Custom weather API integration for gardening calendar
- Plant Information: Trefle API for comprehensive plant database
- Validation: Joi for input validation
- Security: bcryptjs for password hashing, DOMPurify for XSS protection
- File Processing: Formidable and Multer for file uploads
- Utilities: Axios for HTTP requests, date-fns for date manipulation
Greenery_HackCSB_Hackathon_Project/
βββ README.md
βββ Database/ # Database schema and scripts
β βββ Table Creation.sql # Complete database schema
β βββ Table Description.txt # Table relationship documentation
β βββ importantSQL2.sql # Sample data and test queries
β βββ sample.txt # Additional database notes
βββ Nextjs/hackathon-project/ # Main Next.js application
βββ package.json # Dependencies and scripts
βββ next.config.mjs # Next.js configuration
βββ tailwind.config.js # Tailwind CSS configuration
βββ postcss.config.mjs # PostCSS configuration
βββ jsconfig.json # JavaScript configuration
βββ app/ # Next.js App Router structure
β βββ layout.js # Root layout component
β βββ page.js # Landing page
β βββ globals.css # Global styles
β βββ functions.js # Utility functions
β βββ menubar.js # Navigation component
β βββ (auth)/ # Authentication routes
β β βββ login/ # User login
β β βββ signin/ # User registration
β βββ (after-sign-in)/ # Protected routes
β β βββ layout.js # Authenticated user layout
β β βββ MenuOptions.js # Navigation menu configuration
β β βββ community/ # Social networking features
β β βββ forum/ # Q&A system
β β βββ harvest/ # Achievement sharing
β β βββ plants/ # Plant database
β β βββ plant-exploration/ # Local species discovery
β β βββ plant-detection/ # AI plant identification
β β βββ plant-journal/ # Personal gardening logs
β β βββ plant-challenge/ # Milestone tracking
β β βββ calender/ # Weather-based planning
β β βββ marketplace/ # Product catalog
β β βββ chat-ai/ # AI assistant
β β βββ newPost/ # Content creation
β β βββ profile/ # User management
β βββ (articles)/ # Educational content
β β βββ globalwarming/ # Climate change articles
β β βββ plantingtree/ # Tree planting guides
β β βββ temparaturecontrol/ # Climate management
β β βββ disastermanagement/ # Emergency preparedness
β βββ api/ # Backend API routes
β β βββ route.js # Main API router
β β βββ db.js # Database connection
β β βββ validation.js # Input validation
β β βββ sanitization.js # Security utilities
β β βββ plant-identification/ # Plant ID service
β β βββ weatherAPI/ # Weather integration
β β βββ upload-image/ # Image processing
β β βββ [various endpoints] # Feature-specific APIs
β βββ components/ # Reusable UI components
β βββ SearchBar.js # Search functionality
β βββ Filter.js # Filtering components
β βββ ProductGrid.js # Product display
β βββ SortBy.js # Sorting utilities
βββ public/ # Static assets
βββ logo.png # Application branding
βββ [1-13].jpg # Plant images
βββ user/ # User profile images
βββ community/ # Community content
βββ harvest/ # Harvest photos
βββ [various icons] # UI icons and graphics
The application uses a comprehensive PostgreSQL database with the following key entities:
- UserInfo: User profiles with authentication and location data
- CompanyInfo: Business accounts for marketplace vendors
- PlantInfo: Comprehensive plant database with descriptions and images
- Chat: Real-time messaging system between users
- Post: Community posts with plant associations and categorization
- Harvest: User achievements and harvest sharing
- ForumQuestion/ForumAnswer: Q&A system for plant-related queries
- ReactXPost/ReactXHarvest/ReactXAnswer: Reaction system (likes/dislikes)
- CommentXPost/CommentXHarvest: Commenting system
- UserXPlant: Tracking user's planted species and quantities
- Product/UserXProduct/CompanyXProduct: Marketplace functionality
- ProductReview: User feedback and rating system
- Foreign key constraints ensure data integrity across all tables
- Cascade deletions maintain referential consistency
- Timestamp tracking for all user activities
A Facebook-style social platform specifically for gardening enthusiasts.
Technical Implementation:
- Real-time post creation with image upload via Cloudinary
- React-based interaction system (likes/dislikes)
- Nested commenting with user mentions
- Plant association for each post
- Content categorization (advice vs. plantation updates)
Key Files:
app/(after-sign-in)/community/page.jsapp/api/insertNewPost.jsapp/api/getAllCommunityPosts.js
Structured knowledge sharing platform for plant-related queries.
Technical Implementation:
- Plant-specific question categorization
- Upvoting system for answer quality
- User reputation tracking
- Search functionality across questions and answers
Key Files:
app/(after-sign-in)/forum/page.jsapp/api/addForumQuestion.jsapp/api/addForumAnswer.js
Platform for showcasing gardening successes and milestones.
Technical Implementation:
- Image-centric content sharing
- Plant-specific harvest tracking
- Quantity and quality metrics
- Community engagement through reactions and comments
Key Files:
app/(after-sign-in)/harvest/page.jsapp/api/insertNewHarvest.jsapp/api/getAllHarvestPosts.js
Machine learning integration for instant plant recognition.
Technical Implementation:
- Integration with Pl@ntNet API for scientific accuracy
- Multi-organ identification (leaf, flower, fruit, bark)
- Confidence scoring and alternative suggestions
- Detailed species information retrieval
Key Files:
app/(after-sign-in)/plant-detection/page.jsapp/api/plant-identification/route.js
AI-powered gardening advisor using Google Gemini.
Technical Implementation:
- Natural language processing for gardening queries
- Context-aware responses with plant care advice
- Markdown rendering for formatted responses
- Chat history persistence
Key Files:
app/(after-sign-in)/chat-ai/page.js- Google Gemini API integration in
app/api/route.js
16-day weather forecast with gardening activity recommendations.
Technical Implementation:
- Location-based weather data for Bangladesh districts
- Activity optimization (watering, fertilizing, pest control)
- Visual weather indicators and recommendations
- Integration with user's plant journal
Key Files:
app/(after-sign-in)/calender/page.jsapp/api/weatherAPI/route.js
Digital logging system for tracking plant care activities.
Technical Implementation:
- Individual plant tracking with photos and notes
- Growth milestone recording
- Care schedule reminders
- Progress visualization
Key Files:
app/(after-sign-in)/plant-journal/page.jsapp/api/journalFunctions.js
Comprehensive plant information system with local species focus.
Technical Implementation:
- Filterable plant database with scientific names
- Bangladesh-specific plant species information
- Detailed care instructions and characteristics
- Image galleries for plant identification
Key Files:
app/(after-sign-in)/plants/page.jsapp/(after-sign-in)/plant-exploration/page.jsapp/api/fetchPlantData.js
E-commerce functionality for gardening supplies.
Technical Implementation:
- Product categorization (plants, tools, fertilizers, pesticides)
- Search and filtering capabilities
- User reviews and ratings
- Company and individual seller support
Key Files:
app/(after-sign-in)/marketplace/page.jsapp/components/ProductGrid.jsapp/components/Filter.js
Gamification elements to encourage sustained gardening engagement.
Technical Implementation:
- Progressive milestone tracking
- Achievement badges and recognition
- Community challenges and competitions
- Progress visualization and statistics
Key Files:
app/(after-sign-in)/plant-challenge/page.js
Environmental awareness and gardening education platform.
Technical Implementation:
- Article management system for environmental topics
- Climate change awareness content
- Disaster management and plant-based solutions
- Temperature control and sustainability guides
Key Files:
app/(articles)/globalwarming/page.jsapp/(articles)/plantingtree/page.jsapp/(articles)/temparaturecontrol/page.jsapp/(articles)/disastermanagement/page.js
- Node.js (v18 or higher)
- PostgreSQL database
- Cloudinary account for image storage
- API keys for external services
Create a .env.local file in the Nextjs/hackathon-project/ directory:
# Database Configuration
PG_USER=your_postgres_user
PG_HOST=your_postgres_host
PG_DATABASE=your_database_name
PG_PASSWORD=your_postgres_password
PG_PORT=5432
# API Keys
PLANTNET_API_KEY=your_plantnet_api_key
GOOGLE_API_KEY=your_google_gemini_api_key
WEATHER_API_KEY=your_weather_api_key
WEATHER_BASE_URL=your_weather_api_base_url
# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret- Create a PostgreSQL database
- Execute the SQL scripts in order:
psql -U your_user -d your_database -f "Database/Table Creation.sql" - Optionally load sample data:
psql -U your_user -d your_database -f Database/importantSQL2.sql
-
Clone the repository:
git clone https://github.com/TAR2003/Greenery_HackCSB_Hackathon_Project.git cd Greenery_HackCSB_Hackathon_Project/Nextjs/hackathon-project -
Install dependencies:
npm install
-
Configure environment variables (see above)
-
Run the development server:
npm run dev
-
Access the application at
http://localhost:3000
npm run build
npm start- Registration: Create an account through the sign-in page
- Profile Setup: Add your location and gardening interests
- Plant Journal: Start logging your plants and care activities
- Community Engagement: Share posts, ask questions, and connect with other gardeners
- Plant Identification: Use the camera feature to identify unknown plants
- Weather Planning: Check the calendar for optimal gardening activities
- API Endpoints: All backend functionality is accessible through
/api/routes - Authentication: User sessions are managed via HTTP-only cookies
- Database Access: Use the
getPool()function fromapp/api/db.js - Image Uploads: Implement Cloudinary integration for new features
- Validation: Use Joi schemas for input validation
- Security: Implement XSS protection with DOMPurify
- Server-side validation: Joi schemas for all API endpoints
- XSS Protection: DOMPurify for content sanitization
- SQL Injection Prevention: Parameterized queries throughout
- Password Security: bcryptjs hashing with salt
- Session Management: Secure cookie-based authentication
- Route Protection: Middleware for authenticated routes
- SSL Connections: Encrypted database communications
- Foreign Key Constraints: Data integrity enforcement
- Cascade Deletions: Consistent data cleanup
- Type Validation: Restricted file types for uploads
- Size Limits: Configurable upload size restrictions
- Virus Scanning: Integration ready for malware detection
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Make changes following the existing code style
- Test thoroughly with the development database
- Commit with descriptive messages
- Push to your fork and create a pull request
- Use ES6+ JavaScript features
- Follow Next.js App Router conventions
- Implement proper error handling
- Add JSDoc comments for complex functions
- Use semantic HTML and accessible design patterns
- Test all API endpoints with various input scenarios
- Verify database transactions and rollbacks
- Check responsive design across device sizes
- Validate form submissions and error states
This project is developed for educational and hackathon purposes. Please refer to the repository for specific licensing terms.
- APIs: Pl@ntNet for plant identification, Google Gemini for AI assistance
- Frameworks: Next.js team for the excellent full-stack framework
- Community: Open source contributors and gardening enthusiasts
- Hackathon: HackCSB for providing the platform and inspiration
For technical support, feature requests, or contributions:
- Repository: GitHub
- Issues: Use GitHub Issues for bug reports and feature requests
Greenery - Cultivating a sustainable future, one plant at a time π±