Making every ride count towards a greener planet π
Features β’ Demo β’ Installation β’ Documentation β’ Contributing
SustainAride is a full-stack sustainability-focused ride-hailing platform that promotes eco-friendly transportation by encouraging users to choose CNG vehicles, electric vehicles (EVs), and shared rides. The platform gamifies sustainable travel with rewards, coupons, and real-time pollution alerts to reduce COβ emissions and promote green commuting.
Built for environmentally conscious travelers who want to make a positive impact while getting from point A to point B.
-
πΏ Eco-Ride Booking System
- Book rides with Electric, CNG, or Shared vehicles
- Real-time ride tracking with Leaflet maps
- Smart route optimization for reduced emissions
- Multi-step booking flow with driver matching
-
π° Smart Coupon Engine
- Dynamic coupon validation system
- User-specific and ride-type-specific coupons
- Automatic eligibility checking
- Active/expired coupon management
- Predefined eco-friendly coupons:
GreenStart10- βΉ10 off first eco-rideEcoRide20- βΉ20 cashback on 3 shared ridesElectricSaver30- βΉ30 off electric rides >10kmSharedBonus50- βΉ50 off on shared ridesReferralRide100- βΉ100 referral bonus
-
π Rewards & Gamification
- Earn SustainPoints for eco-friendly rides
- Redeem rewards from partner brands
- Achievement badges and milestones
- Emergency pollution alert bonuses
-
π Carbon Footprint Tracking
- Real-time COβ savings calculator
- Impact dashboard with visualizations
- Trees planted equivalent metric
- Monthly/weekly environmental reports
-
π¨ Real-Time AQI Monitoring
- Live Air Quality Index tracking (Delhi)
- Emergency pollution mode activation (AQI > 200)
- Bonus eco-rewards during high pollution
- Test pollution mode for development
-
π Secure Authentication
- JWT-based authentication
- BCrypt password hashing
- Token expiration and refresh
- Protected routes and API endpoints
- Auto-logout on token expiry
-
π¨βπΌ User Profiles
- Customizable user profiles
- Profile picture upload
- Ride history tracking
- SustainPoints wallet
- Coupon & reward management
-
π Modern UI/UX
- Dark/Light theme support
- Fully responsive design (mobile-first)
- Smooth animations with Framer Motion
- Beautiful Shadcn/UI components
- Interactive Storybook components
-
π± Progressive Web Features
- Offline mode support
- Real-time backend status monitoring
- Network error handling
- Optimistic UI updates
- Framework: React 18 with TypeScript
- Build Tool: Vite 6
- Styling: Tailwind CSS 3.4
- UI Components: Radix UI + Shadcn/UI
- Animations: Framer Motion
- Forms: React Hook Form + Zod validation
- Routing: React Router v6
- Maps: Leaflet + React Leaflet
- State Management: React Context API
- HTTP Client: Axios
- Runtime: Node.js 24.x
- Framework: Express.js 5
- Database: MongoDB with Mongoose ODM
- Authentication: JWT (jsonwebtoken)
- Security:
- Helmet (HTTP headers)
- CORS
- BCrypt (password hashing)
- Express Rate Limit
- Mongo Sanitize
- Task Scheduling: Node-cron
- Caching: Node-cache
- Deployment: Vercel (Frontend & Serverless Functions)
- Development:
- Concurrently (parallel scripts)
- Nodemon (hot reload)
- TypeScript 5
- ESLint
- Component Development: Tempo Devtools & Storybook
- Node.js 18+ (recommended: 24.x)
- MongoDB Atlas account or local MongoDB
- Git
git clone https://github.com/yourusername/SustainAride.git
cd SustainAridenpm installCreate a server/config.env file:
# MongoDB Connection
ATLAS_URI=your_mongodb_connection_string
# JWT Configuration
JWT_SECRET=your_jwt_secret_key
# Server Configuration
PORT=5000
NODE_ENV=development
# Air Quality API (optional)
AQI_API_KEY=your_aqi_api_keyCreate a .env file in the root (for frontend):
VITE_API_URL=http://localhost:5000
VITE_TEMPO=falseOption 1: Start Frontend & Backend Together
npm run dev:allOption 2: Start Separately
Terminal 1 - Backend:
npm run serverTerminal 2 - Frontend:
npm run devThe app will be available at:
- Frontend:
http://localhost:5173 - Backend API:
http://localhost:5000
SustainAride/
βββ src/ # Frontend source code
β βββ api/ # API service layers
β β βββ apiClient.ts # Axios client configuration
β β βββ authService.ts # Authentication API
β β βββ couponService.ts # Coupon management API
β β βββ rewardService.ts # Rewards API
β β βββ rideService.ts # Ride booking API
β β βββ userService.ts # User management API
β βββ components/ # React components
β β βββ auth/ # Authentication components
β β βββ map/ # Map components
β β βββ ui/ # Reusable UI components
β β βββ Dashboard.tsx # User dashboard
β β βββ Profile.tsx # User profile
β β βββ RideBookingFlow.tsx # Ride booking interface
β β βββ ...
β βββ contexts/ # React Context providers
β β βββ AuthContext.tsx # Authentication context
β βββ types/ # TypeScript type definitions
β β βββ api.ts # API type definitions
β βββ lib/ # Utility libraries
β βββ stories/ # Storybook stories
β βββ App.tsx # Main app component
β βββ main.tsx # App entry point
βββ server/ # Backend source code
β βββ controllers/ # Request handlers
β β βββ authController.cjs # Authentication logic
β β βββ rewardController.cjs # Rewards logic
β β βββ aqiController.cjs # AQI monitoring
β βββ models/ # MongoDB schemas
β β βββ User.cjs # User model
β β βββ Ride.cjs # Ride model
β β βββ Coupon.cjs # Coupon model
β β βββ Reward.cjs # Reward model
β βββ routes/ # API route definitions
β β βββ authRoutes.cjs # Auth endpoints
β β βββ userRoutes.cjs # User endpoints
β β βββ rideRoutes.cjs # Ride endpoints
β β βββ couponRoutes.cjs # Coupon endpoints
β β βββ rewardRoutes.cjs # Reward endpoints
β βββ middlewares/ # Express middlewares
β β βββ auth.cjs # JWT verification
β βββ utils/ # Utility functions
β β βββ couponEngine.cjs # Coupon validation engine
β β βββ scheduler.cjs # Cron jobs
β βββ db.cjs # Database connection
β βββ server.cjs # Express server
β βββ config.env # Environment variables
βββ api/ # Vercel serverless functions
β βββ auth/ # Auth endpoints
β βββ coupons/ # Coupon endpoints
β βββ aqi/ # AQI endpoints
βββ public/ # Static assets
βββ package.json # Dependencies
βββ tsconfig.json # TypeScript config
βββ tailwind.config.js # Tailwind configuration
βββ vite.config.ts # Vite configuration
βββ vercel.json # Vercel deployment config
POST /api/auth/register
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "securePassword123",
"phone": "1234567890"
}POST /api/auth/login
Content-Type: application/json
{
"email": "john@example.com",
"password": "securePassword123"
}GET /api/auth/verify
Authorization: Bearer <token>GET /api/users/:id
Authorization: Bearer <token>PUT /api/users/:id
Authorization: Bearer <token>
Content-Type: application/json
{
"name": "John Updated",
"phone": "9876543210"
}GET /api/users/:id/rides
Authorization: Bearer <token>GET /api/users/:id/coupons
Authorization: Bearer <token>GET /api/couponsGET /api/coupons/user/:userId/activePOST /api/coupons/validate
Content-Type: application/json
{
"code": "GreenStart10",
"userId": "user_id",
"rideType": "Electric",
"rideValue": 100
}POST /api/rides
Authorization: Bearer <token>
Content-Type: application/json
{
"userId": "user_id",
"type": "Electric",
"pickupLocation": {
"coordinates": [77.1025, 28.7041],
"address": "Connaught Place, Delhi"
},
"dropoffLocation": {
"coordinates": [77.2090, 28.6139],
"address": "India Gate, Delhi"
},
"distance": 8.5,
"estimatedPrice": 150
}GET /api/rides/:id
Authorization: Bearer <token>GET /api/rewardsPOST /api/rewards/claim-eco-bonus
Authorization: Bearer <token>
Content-Type: application/json
{
"userId": "user_id"
}POST /api/rewards/:id/redeem
Authorization: Bearer <token>
Content-Type: application/json
{
"userId": "user_id"
}GET /api/aqi/delhiGET /api/aqi/alert-statusThe project includes a comprehensive Storybook for UI components:
npm run storybookAvailable component stories:
- Buttons, Cards, Forms
- Alerts, Dialogs, Modals
- Navigation, Menus
- Data display components
- And more...
- Authentication: JWT-based with 7-day expiration
- Password Security: BCrypt hashing with salt rounds
- API Security:
- Rate limiting
- CORS protection
- Helmet security headers
- MongoDB injection prevention
- Protected Routes: Frontend and backend route protection
- Token Management: Automatic logout on expiry
- Environment Variables: Sensitive data protection
- Install Vercel CLI
npm i -g vercel- Deploy
vercel- Set Environment Variables in Vercel Dashboard:
ATLAS_URIJWT_SECRETNODE_ENV=production
- Create a MongoDB Atlas account
- Create a new cluster
- Get your connection string
- Add to
config.envor environment variables
A test pollution button is available in the UI to simulate high AQI conditions:
- Activates emergency eco-bonus mode
- Triggers pollution alerts
- Tests coupon eligibility during high pollution
Test backend endpoints:
node server/test-api.cjs{
name: String,
email: String (unique),
password: String (hashed),
phone: String,
sustainPoints: Number,
rides: [Ride],
coupons: [Coupon],
rewards: [Reward],
joinDate: Date
}{
user: ObjectId,
type: Enum ['Electric', 'CNG', 'Shared'],
pickupLocation: Location,
dropoffLocation: Location,
distance: Number,
carbonSaved: Number,
price: Number,
status: Enum ['Pending', 'Confirmed', 'Completed']
}{
code: String (unique),
description: String,
discountType: Enum ['Fixed', 'Percentage'],
discountValue: Number,
validFrom: Date,
validUntil: Date,
applicableRideTypes: [String],
usageLimit: Number,
isActive: Boolean
}We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch
git checkout -b feature/AmazingFeature
- Commit your changes
git commit -m 'Add some AmazingFeature' - Push to the branch
git push origin feature/AmazingFeature
- Open a Pull Request
- Follow TypeScript best practices
- Write meaningful commit messages
- Add comments for complex logic
- Update documentation for new features
- Test thoroughly before submitting PR
- Profile picture upload (UI ready, backend pending)
- Real-time ride tracking (simulated)
- Payment gateway integration (planned)
- Real-time driver tracking
- Push notifications
- Social sharing features
- Advanced analytics dashboard
- Driver companion app
- Multi-language support
- Payment gateway integration
- Ride scheduling
- Corporate accounts
This project is licensed under the MIT License - see the LICENSE file for details.
Dhruv
- GitHub: @dhruv552
- Project Link: https://github.com/dhruv552/SustainAride
- Shadcn/UI for beautiful components
- Radix UI for accessible primitives
- OpenStreetMap for mapping services
- MongoDB Atlas for database hosting
- Vercel for deployment platform
If you have any questions or need help:
- Open an issue: GitHub Issues
- Email: support@sustainaride.com
- Documentation: Check the Wiki