A bike rental management backend powered by Supabase (PostgreSQL + Auth + APIs) and Node.js/Express.
- 🔐 Authentication: Supabase Auth with email/password signup/login
- 👥 Role-based Access: Admin and Customer roles with protected endpoints
- 🚲 Bike Management: CRUD operations for bikes with location tracking
- 📅 Rental System: Complete bike booking and return workflow
- 💰 Revenue Tracking: Admin analytics and reporting
- 🔒 Security: JWT authentication, rate limiting, input validation
- 📝 Logging: Request logging and error handling
- 🚀 Production Ready: Deployment configs for Vercel/Render/Netlify
- Node.js 16+
- Supabase account and project
- Clone and install dependencies:
npm install- Copy environment variables:
cp .env.example .env- Update
.envwith your Supabase credentials:
SUPABASE_URL=your_supabase_project_url
SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key- Set up database schema:
npm run migrate- Start development server:
npm run devThe server will run on http://localhost:3000
POST /auth/signup- User registrationPOST /auth/login- User login
GET /bikes- Get all bikesPOST /bikes- Add new bikePUT /bikes/:id- Update bikeDELETE /bikes/:id- Delete bike
POST /rent- Book a bikePOST /return- Return a bikeGET /my-bookings- Get user's bookings
GET /bookings- All bookings (Admin)GET /revenue- Revenue analytics (Admin)
- id: uuid (primary key)
- role: text ("admin" or "customer")
- name: text
- created_at: timestamp- id: serial (primary key)
- model: varchar
- price_per_hour: numeric
- is_available: boolean
- latitude: float
- longitude: float
- created_at: timestamp- booking_id: serial (primary key)
- user_id: uuid (foreign key)
- bike_id: int (foreign key)
- start_time: timestamp
- end_time: timestamp
- total_cost: numeric
- created_at: timestampsrc/
├── config/ # Configuration files
├── middleware/ # Express middleware
├── routes/ # API route handlers
├── services/ # Business logic & Supabase interactions
├── utils/ # Utility functions
└── server.js # Main application entry point
sql/ # Database migration files
scripts/ # Utility scripts
vercel --prodPush to GitHub and connect your repository to Render.
Make sure to set all required environment variables in your hosting platform.
npm run dev # Start development server
npm test # Run tests
npm run migrate # Run database migrations- JWT token verification
- Role-based access control
- Rate limiting (100 requests per 15 minutes)
- Input validation and sanitization
- CORS protection
- Security headers with Helmet
- Environment variable protection
MIT