A comprehensive web application that leverages AI to analyze the environmental footprint of consumer products. Users can input product details through multiple methods including manual forms, receipt uploads with OCR processing, and voice input. The application provides detailed sustainability reports, AI-generated eco-friendly product recommendations, and comprehensive analytics to help users make informed, environmentally conscious purchasing decisions.
- AI-Powered Sustainability Analysis: Advanced machine learning algorithms assess carbon footprint, water usage, recyclability, and overall environmental impact
- Multi-Modal Input: Support for manual entry, receipt scanning, and voice commands
- Personalized Recommendations: AI suggests eco-friendly alternatives based on product characteristics
- Comprehensive Dashboard: Track environmental impact trends, category breakdowns, and sustainability goals
- User-Centric Design: Responsive interface with dark mode, favorites system, and bulk operations
- AI-Powered Analysis: Utilizes advanced machine learning algorithms to assess environmental impact including carbon footprint, water usage, and recyclability.
- Product Recommendations: AI-generated eco-friendly alternatives based on category, material, price, and sustainability score, displayed compactly in the product details section on the show page.
- User Authentication: Secure user accounts with Passport.js for personalized product tracking, including password reset via email verification and account deletion.
- Product Input Methods:
- Manual form input for product details
- Receipt upload with OCR processing using Tesseract.js
- Voice input for hands-free data entry
- Product Management: View, edit, and delete saved products with impact analysis.
- Bulk Delete: Select multiple products from the product list and delete them all at once for efficient management.
- Favorites/Bookmarks: Star important products for quick access and view them in a dedicated 'Favourites' page with search and filter options.
- Comparison Tool: Compare environmental impacts between different products.
- Dashboard: Comprehensive analytics including total CO2 footprint over time, category breakdown, monthly comparisons, and identification of top environmental impact products.
- Dark Mode: Toggle between light and dark themes for comfortable viewing in different lighting conditions.
- Responsive Design: Mobile-friendly interface with modern CSS and animations.
- Security: Rate limiting, input sanitization, and CSRF protection.
- At the end of the goal's timeframe, an email will be automatically sent to the user indicating whether the goal was achieved. If the goal is met, a congratulatory badge will be included in the email; otherwise, an encouraging message will be sent.
- The user profile will include a dedicated section to display all earned badges.
- Node.js with Express.js framework
- MongoDB with Mongoose ODM
- Passport.js for authentication
- Groq SDK for AI analysis
- Tesseract.js for OCR on receipts
- Multer for file uploads
- Nodemailer for email services
- EJS templating engine with ejs-mate
- CSS3 with custom properties and animations
- JavaScript for client-side interactions
- Font Awesome for icons
- Helmet for security headers
- express-rate-limit for API rate limiting
- express-mongo-sanitize for MongoDB injection prevention
- Joi for input validation
- connect-flash for flash messages
You can access the live link of the app here
- Node.js (v16 or higher)
- MongoDB (local installation or cloud service like MongoDB Atlas)
- Git for version control
-
Clone the repository:
git clone https://github.com/DevOlabode/AI-environmental-impact-analyzer.git cd AI-environmental-impact-analyzer -
Install dependencies:
npm install
This will install all required packages including Express, Mongoose, Passport, Groq SDK, and other dependencies.
-
Environment Configuration: Create a
.envfile in the root directory with the following variables:# Application Settings SECRET=your-super-secure-session-secret-here PORT=3000 # Database Configuration DATABASE_URL=mongodb://localhost:27017/ai-environmental-analyzer # AI Service (Groq) GROQ_KEY=your-groq-api-key-here # Email Service (for password reset) EMAIL_HOST=smtp.gmail.com EMAIL_PORT=587 EMAIL_USER=your-email@gmail.com EMAIL_PASS=your-app-password # Optional: Cloudinary for image storage (if using cloud uploads) CLOUDINARY_CLOUD_NAME=your-cloud-name CLOUDINARY_KEY=your-api-key CLOUDINARY_SECRET=your-api-secret
-
Database Setup:
- Local MongoDB: Ensure MongoDB is running on port 27017
- MongoDB Atlas: Update
DATABASE_URLwith your Atlas connection string - The application will automatically create collections when first run
-
AI Service Setup:
- Sign up for Groq and get your API key
- Add the key to your
.envfile asGROQ_KEY
-
Run the application:
# Production mode npm start # Development mode (with auto-restart) npx nodemon index.js
-
Access the application: Open your browser and navigate to
http://localhost:3000
- Port already in use: Change the PORT in
.envor kill the process using that port - MongoDB connection error: Verify MongoDB is running and connection string is correct
- AI service errors: Check your Groq API key and internet connection
-
Create Account: Register with your email and password to access personalized features like saving products and viewing analytics.
-
Dashboard Overview: After logging in, visit your dashboard to see:
- Total environmental impact summary
- Monthly trends and comparisons
- Category-wise breakdown of your consumption
- Top impact products identification
- Navigate to "Add Product" from the main menu
- Fill in product details: name, brand, category, material, weight, origin country, price
- Submit to get instant AI analysis and recommendations
- Go to "Upload Receipt" section
- Upload a clear image of your receipt
- AI automatically extracts product information using OCR
- Review and confirm extracted data before saving
- Access "Voice Input" feature
- Speak product details clearly
- AI transcribes and processes your voice input
- Review transcribed data and submit for analysis
Each product analysis includes:
- Sustainability Score (1-10): Overall environmental rating
- Carbon Footprint: CO2 emissions in kg
- Water Usage: Water consumption in liters
- Recyclability: Low/Medium/High rating
- AI Explanation: Detailed reasoning for the scores
- Browse all your analyzed products
- Search by name, brand, or category
- Filter by category or brand
- Sort by date, sustainability score, or impact
- Star important products for quick access
- View dedicated favorites page with same search/filter capabilities
- Toggle favorite status from product detail or list view
- Select multiple products using checkboxes
- Delete multiple products at once
- Efficient management for large product collections
- Select multiple products to compare side-by-side
- View detailed environmental metrics comparison
- Identify which products have better sustainability profiles
- Modify product details after initial analysis
- Re-run AI analysis with updated information
- Update impact calculations automatically
- Accurate Data Entry: Provide as much detail as possible for better analysis accuracy
- Regular Monitoring: Use the dashboard to track your environmental impact over time
- Eco-Friendly Choices: Review AI recommendations to make sustainable purchasing decisions
- Data Management: Regularly review and clean up old/unnecessary product entries
- Analysis Errors: Ensure all required fields are filled and data is realistic
- Upload Issues: Check image quality for receipt uploads (clear, well-lit images work best)
- Voice Recognition: Speak clearly and in a quiet environment for best transcription results
- Performance: Large product collections may load slower; consider archiving old entries
AI-environmental-impact-analyzer/
├── controllers/ # Route handlers
│ ├── auth.js
│ ├── comparison.js
│ ├── dashboard.js
│ ├── form.js
│ ├── receipt.js
│ ├── user.js
│ └── voiceInput.js
├── models/ # Mongoose schemas
│ ├── impact.js
│ ├── product.js
│ └── user.js
├── public/ # Frontend CSS and JS Code
│ ├── css/
│ ├── images/
│ └── js/
├── routes/ # Express routes
│ ├── auth.js
│ ├── comparison.js
│ ├── dashboard.js
│ ├── form.js
│ ├── receipt.js
│ ├── user.js
│ └── voiceInput.js
├── utils/ # Utility functions
│ ├── AI.js
│ ├── catchAsync.js
│ ├── emailService.js
│ ├── expressError.js
│ ├── mongoSanitizev5.js
│ └── multer.js
├── views/ # EJS templates
│ ├── auth/
│ ├── comparison/
│ ├── dashboard/
│ ├── form/
│ ├── layout/
│ ├── partials/
│ ├── receipt/
│ ├── user/
│ └── voiceInput/
├── middleware.js # Custom middleware
├── schema.js # Validation schemas
├── index.js # Main application file
├── package.json
└── README.md
GET /- Home pageGET /register- User registrationPOST /register- Register new userGET /login- User loginPOST /login- Authenticate userGET /logout- Logout userGET /form- Product input formPOST /form/input- Submit product dataGET /form/all-products- View all user productsGET /form/show-products/:id- View specific productGET /form/edit/:id- Edit product formPUT /form/edit/:id- Update productDELETE /form/delete/:id- Delete productPOST /form/toggle-favorite/:id- Toggle favorite status for a productGET /form/favorites- View favorited productsGET /receipt- Receipt upload pagePOST /receipt/upload- Process receipt uploadGET /comparison- Product comparison pagePOST /comparison/compare- Compare productsGET /dashboard- User dashboardGET /user/profile- User profilePUT /user/profile- Update profileDELETE /delete-account- Delete user accountGET /voice-input- Voice input page
-
Local Development:
npm run dev # Uses nodemon for auto-restart -
Testing:
- Test AI analysis with various product types
- Verify OCR accuracy with different receipt formats
- Check responsive design across devices
- Validate form inputs and error handling
-
Code Quality:
- Follow ESLint configuration for JavaScript
- Use consistent naming conventions
- Add JSDoc comments for complex functions
- Validate all environment variables
- Connect your GitHub repository to Render
- Set environment variables in Render dashboard
- Deploy automatically on git push
- Use MongoDB Atlas for database
- Create Heroku app
- Set buildpacks for Node.js
- Configure environment variables
- Deploy via git push or GitHub integration
- Connect repository
- Configure environment variables
- Set up MongoDB database
- Deploy with automatic SSL
| Variable | Description | Required | Default |
|---|---|---|---|
SECRET |
Session secret key | Yes | - |
PORT |
Server port | No | 3000 |
DATABASE_URL |
MongoDB connection string | Yes | - |
GROQ_KEY |
Groq AI API key | Yes | - |
EMAIL_HOST |
SMTP host | No | - |
EMAIL_PORT |
SMTP port | No | 587 |
EMAIL_USER |
SMTP username | No | - |
EMAIL_PASS |
SMTP password | No | - |
- Database Indexing: Ensure proper indexes on frequently queried fields
- Image Optimization: Compress receipt images before upload
- Caching: Implement Redis for session storage in production
- Rate Limiting: Configure appropriate limits for AI API calls
- CDN: Use CDN for static assets in production
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes following our coding standards
- Test thoroughly on different devices and browsers
- Commit with clear, descriptive messages
- Code Style: Follow existing code patterns and ESLint rules
- Documentation: Update README and add JSDoc comments for new functions
- Testing: Test all new features across different input methods
- Security: Ensure no security vulnerabilities are introduced
- Performance: Optimize for speed and efficiency
- Update the README.md with details of changes if needed
- Ensure all tests pass and no linting errors
- Provide clear description of the changes and their purpose
- Wait for review and address any feedback
- AI Model Improvements: Enhance analysis accuracy and add new metrics
- UI/UX Enhancements: Improve responsive design and user experience
- New Features: Additional input methods or analysis categories
- Performance Optimization: Database queries, API calls, and frontend rendering
- Internationalization: Multi-language support
- Accessibility: WCAG compliance improvements
- API Keys: Never commit API keys to version control
- Input Validation: All user inputs are validated using Joi schemas
- Rate Limiting: API endpoints are protected against abuse
- Data Sanitization: MongoDB injection prevention implemented
- Session Security: Secure session configuration with httpOnly cookies
- CSRF Protection: All forms protected against cross-site request forgery
This project is licensed under the ISC License - see the LICENSE file for details.
- Issues: Report bugs and request features via GitHub Issues
- Discussions: Join community discussions on GitHub
- Documentation: Check the wiki for detailed guides
- AI Analysis: Powered by Groq for fast, efficient AI processing
- OCR Functionality: Tesseract.js for receipt text extraction
- Icons: Font Awesome for beautiful, consistent iconography
- UI Framework: Custom CSS with modern design principles
- Community: Thanks to all contributors and users for their support and feedback
Made with ❤️ for a sustainable future