A full-stack e-commerce platform focused on sustainable products with carbon footprint tracking and ML-powered recommendations.
This platform combines e-commerce functionality with environmental consciousness, featuring:
- Sustainable Product Marketplace - Products with eco-friendly packaging and carbon impact tracking
- ML-Powered Recommendations - Carbon footprint analysis and product suggestions
- Role-Based Authentication - Admin and customer user management
- Real-time Analytics - Environmental impact dashboard
Merge-Conflict/
βββ client/ # Next.js 15 frontend
βββ server/ # Node.js + Express API
βββ ml/ # Python ML service (FastAPI)
βββ .github/ # CI/CD workflows
βββ scripts/ # Service management scripts
- Framework: Next.js 15 with TypeScript
- Styling: Tailwind CSS + Radix UI components
- State Management: Redux Toolkit + Redux Persist
- Authentication: JWT with role-based access
- Runtime: Node.js with TypeScript
- Framework: Express.js
- Database: PostgreSQL with Drizzle ORM
- Authentication: JWT + bcrypt
- Migration: Drizzle migrations
- Framework: FastAPI (Python)
- ML Library: scikit-learn (Random Forest)
- Model: Carbon footprint prediction
- Data Processing: pandas, numpy
- Node.js 18+ and npm
- Python 3.8+ and pip
- PostgreSQL database
- Git
git clone <repository-url>
cd Merge-Conflict# Create PostgreSQL database
createdb your_database_nameServer (.env)
DATABASE_URL="postgresql://username:password@localhost:5432/database_name"
JWT_SECRET="your-super-secret-jwt-key"
PORT=4000Client (.env)
NEXT_PUBLIC_API_URL=http://localhost:4000Server:
cd server
npm installClient:
cd client
npm installML Service:
cd ml
pip install -r requirements.txtcd server
npm run migrate
npm run seedStart Server:
cd server
npm run devStart Client:
cd client
npm run devStart ML Service:
cd ml
python -m uvicorn main:app --host 0.0.0.0 --port 8000Start all services:
chmod +x launch_services.sh
./launch_services.shView logs:
./view_logs.sh ml # ML service logs
./view_logs.sh server # Server logs
./view_logs.sh -a # All logs
./view_logs.sh -f server # Follow server logsStop all services:
./stop_services.sh- Client (Frontend): http://localhost:3000
- Server (API): http://localhost:4000
- ML Service: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Browse eco-friendly products
- View carbon impact scores
- Add products to cart
- Product reviews and ratings
- Sustainable packaging options
- Product management (CRUD)
- User management
- Analytics dashboard
- Carbon footprint tracking
- Order management
Email: admin@gmail.com
Password: admin123
Role: admin
# Login
POST /api/users/login
{
"email": "user@example.com",
"password": "password",
"role": "admin" | "customer"
}
# Protected routes require Authorization header
Authorization: Bearer <jwt_token>- Users: Authentication and profile management
- Products: Eco-friendly product catalog
- PackagingTypes: Sustainable packaging options
- Reviews: Product reviews and ratings
- Orders: Purchase transactions
{
title: "Eco-Friendly Notebook",
brand: "EcoWrite",
carbonImpact: "1.20",
packagingType: "Recyclable Paper",
ecoTags: ["recycled", "sustainable"],
supportsEcoPackaging: true
}- Model: Random Forest Regressor
- Features: Product weight, materials, packaging type
- Endpoint:
POST /predict-carbon-footprint
{
"weight": 1.0,
"material1": "Paper",
"material2": "Plastic",
"packaging_type": "Recyclable"
}npm run dev # Development mode
npm run build # Build for production
npm run migrate # Run database migrations
npm run seed # Seed sample datanpm run dev # Development mode
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintPOST /api/users/register- User registrationPOST /api/users/login- User login
GET /api/products- Get all productsGET /api/products/:id- Get product by IDPOST /api/products- Create product (Admin only)PUT /api/products/:id- Update product (Admin only)DELETE /api/products/:id- Delete product (Admin only)
POST /predict-carbon-footprint- Predict product carbon impactGET /health- Service health check
# Run client tests
cd client
npm test
# Run server tests
cd server
npm test
# Test ML service
cd ml
python -m pytestdocker-compose up --build- Build client:
npm run build - Setup production database
- Configure environment variables
- Deploy to your preferred platform (Vercel, Railway, etc.)
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open Pull Request
This project is licensed under the MIT License.
Database Connection Issues:
# Check PostgreSQL is running
sudo systemctl status postgresql
# Verify database exists
psql -lPort Already in Use:
# Kill process on port
sudo fuser -k 3000/tcp # For client
sudo fuser -k 4000/tcp # For server
sudo fuser -k 8000/tcp # For ML serviceMigration Errors:
# Reset database
cd server
npm run migrate:reset
npm run seedFor support and questions:
- Create an issue in the repository
- Check existing documentation
- Review logs:
./view_logs.sh -a
Made with π± for a sustainable future