A modern bike-sharing platform designed for college campuses with hardware integration capabilities.
CampusCycle is a college cycle-sharing application that enables students to book and return bicycles seamlessly. Built with scalability and hardware integration in mind, it features:
- π User Authentication - Secure session-based login system
- π΄ Cycle Management - Real-time booking and return functionality
- π± Mobile-First - Cross-platform React Native mobile application
- π Hardware Ready - Designed for ESP32/MQTT integration
- π Analytics Ready - Foundation for ride tracking and statistics
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Expo App β β Node.js Backend β β ESP32 β
β (React Native) ββββββββββΊβ (Port 3000) ββββββββββΊβ Hardware β
βββββββββββββββββββ REST ββββββββββββββββββββ HTTP βββββββββββββββββββ
β β
POST /api/book βββββββββββββββ€ β
POST /api/return βββββββββββββ€ β
GET /api/cycles βββββββββββββ€ β
β β
POST /rfid ββββββββββββββββββββββββββ€ Cycle RFID Tag
GET /command ββββββββββββββββββββββββΊ Unlock/Lock
Important: The RFID tags are attached to cycles, not users.
- Each cycle (A, B, C, D) has a unique RFID tag
- When a cycle is docked, the station reads its RFID
- Backend identifies which cycle was returned
Booking Flow (App β Hardware):
User books cycle in app β Backend sets unlock=true β ESP32 polls /command β Lock opens π
Return Flow (Hardware β Backend):
User docks cycle β RFID reader scans cycle tag β ESP32 sends to /rfid β Backend marks cycle AVAILABLE β Lock closes π
- Node.js 18+ and npm 9+
- Expo Go app (for mobile testing)
- Same WiFi network for phone and computer
-
Clone the repository
git clone https://github.com/Srishanth-023/CampusCycle.git cd CampusCycle -
Install dependencies
# Backend cd backend npm install # Mobile App cd ../mobile-app npm install --legacy-peer-deps
-
Configure API URL
Get your local IP:
hostname -I | awk '{print $1}'
Update
mobile-app/App.jsline 18:const API_BASE_URL = 'http://YOUR_IP:3000/api';
-
Start the application
Terminal 1 (Backend):
cd backend node server.jsTerminal 2 (Mobile App):
cd mobile-app npm start -
Access the app
- Scan QR code with Expo Go app
- Or press
wfor web version
π For detailed setup instructions, see SETUP.md
- β User authentication with session management
- β Real-time cycle availability tracking
- β Booking system with OTP generation
- β Return system with ride statistics
- β Connection testing functionality
- β Cross-platform mobile support
- β ESP32 Hardware Integration
- β RFID-based cycle return
- β Remote unlock via app
- π Database integration (MongoDB)
- π Multi-station support
- π User registration system
- π Payment gateway integration
- π GPS tracking
- π Push notifications
- π Admin dashboard
| Component | Purpose |
|---|---|
| ESP32 Dev Board | Main controller |
| RFID Reader (RC522/EM18) | Card scanning |
| Relay Module (5V) | Lock control |
| Solenoid/Electric Lock | Physical lock |
ESP32 Pin β Component
βββββββββββββββββββββββββββββ
GPIO 16 β RFID Reader (RX)
GPIO 26 β Relay Module (IN)
5V β Power Rails
GND β Ground Rails
Update the following in hardware.md before flashing:
/* ================= WIFI CONFIG ================= */
const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";
/* ================= BACKEND URLs ================= */
const char* POST_URL = "http://YOUR_BACKEND_IP:3000/rfid";
const char* GET_URL = "http://YOUR_BACKEND_IP:3000/command";# Linux/Mac
hostname -I | awk '{print $1}'
# Windows
ipconfig | findstr IPv4| Endpoint | Method | Purpose |
|---|---|---|
/rfid |
POST | ESP32 sends cycle RFID when docked |
/command |
GET | ESP32 polls for unlock command |
/command/unlock |
POST | App triggers unlock |
/api/rfid/tags |
GET | List cycle RFID registrations |
/api/hardware/status |
GET | Debug hardware state |
| Trigger | Action | Auto-Revert |
|---|---|---|
| App Booking | UNLOCK | Lock after 20s |
| RFID Tap | LOCK | Open after 10s |
| Startup | OPEN | β (default) |
Each cycle has an RFID tag attached to it. When a cycle is returned to the station:
- User docks the cycle at the station
- RFID reader scans the cycle's tag
- ESP32 sends the RFID to backend
- Backend identifies which cycle was returned
- Backend marks that cycle as AVAILABLE
- User's ride is completed
Add your cycle RFID tags in backend/server.js:
// Around line 40 - Map RFID tags to cycles
rfidToCycle.set("123456789", "A"); // Cycle A's RFID tag
rfidToCycle.set("987654321", "B"); // Cycle B's RFID tag
rfidToCycle.set("111222333", "C"); // Cycle C's RFID tag
rfidToCycle.set("444555666", "D"); // Cycle D's RFID tagTo find an RFID tag number:
- Flash ESP32 and open Serial Monitor (115200 baud)
- Scan the RFID tag attached to a cycle
- Look for:
RFID DEC: 123456789β Use this number - Register it to the corresponding cycle ID
- Runtime: Node.js 18+
- Framework: Express.js
- Authentication: Session tokens (in-memory)
- Data Storage: In-memory (v1.0)
- Framework: React Native
- SDK: Expo 51
- State Management: React Hooks
- Navigation: Expo Router
- Microcontroller: ESP32
- Communication: HTTP REST (polling)
- RFID: EM18/RC522 compatible
- Lock Control: Relay-based
hostname -I | awk '{print $1}'
# Example output: 192.168.1.100cd backend
npm install
node server.jsExpected output:
π CampusCycle Backend running on http://localhost:3000
π Station: Main Station
π² Cycles: 4 total
π RFID Tags: 4 registered to cycles
Update client-app/services/api.ts:
const API_BASE_URL = Platform.OS === 'web'
? 'http://localhost:3000/api'
: 'http://192.168.1.100:3000/api'; // β Your IPcd client-app
npm install
npm startPress w for web or scan QR with Expo Go.
Update hardware.md:
const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASS = "YOUR_PASSWORD";
const char* POST_URL = "http://192.168.1.100:3000/rfid";
const char* GET_URL = "http://192.168.1.100:3000/command";Flash to ESP32 using Arduino IDE.
| Username | Password | Role |
|---|---|---|
admin |
password |
Administrator |
student |
student123 |
Student |
- Test Connection: Verify backend connectivity
- Login: Use demo credentials
- Book Cycle: Select available cycle
- Return Cycle: Complete ride and view stats
# Health check
curl http://localhost:3000/api/health
# Login
curl -X POST http://localhost:3000/api/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"password"}'# Check hardware status
curl http://localhost:3000/api/hardware/status
# Simulate ESP32 RFID scan
curl -X POST http://localhost:3000/rfid \
-H "Content-Type: application/json" \
-d '{"rfid":"123456789"}'
# Check unlock command (ESP32 polls this)
curl http://localhost:3000/command
# Trigger unlock (after login)
TOKEN="your_token_here"
curl -X POST http://localhost:3000/command/unlock \
-H "Authorization: Bearer $TOKEN"When working correctly, you should see:
WiFi Connected
SYSTEM READY
LOCK STATUS: OPEN π
--------------------------------
POST /rfid STATUS: 200 β RFID working
GET /command STATUS: 200 β Polling working
WEB COMMAND: UNLOCK β Unlock received
RFID HEX: A1B2C3D4E5
RFID DEC: 123456789
LOCK CLOSED BY RFID π
CampusCycle/
βββ backend/ # Node.js API server
β βββ server.js # Main server with hardware endpoints
β βββ package.json # Dependencies
β
βββ client-app/ # Expo React Native app
β βββ app/ # Screen components
β βββ services/api.ts # API service
β βββ context/ # Auth & Theme context
β βββ package.json # Dependencies
β
βββ hardware.md # ESP32 Arduino code
βββ README.md # This file
βββ SETUP.md # Detailed setup guide
| Issue | Solution |
|---|---|
| Port 3000 in use | lsof -ti:3000 | xargs kill -9 |
| Cannot connect | Check same WiFi & IP address |
| SDK mismatch | Reinstall with --legacy-peer-deps |
| Metro bundler | Clear cache: npm start -- --clear |
| Issue | Solution |
|---|---|
| ESP32 won't connect WiFi | Use 2.4GHz network, check credentials |
| HTTP -1 or 404 errors | Verify backend IP in ESP32 code |
| RFID not recognized | Register card in server.js, check decimal number |
| Lock not responding | Check relay wiring (GPIO 26), test relay LED |
| Unlock not working | Verify ESP32 polls show 200 status |
- Backend running?
curl http://localhost:3000/api/health - ESP32 connected to WiFi? Check Serial Monitor
- Same network? Phone, computer, ESP32 on same WiFi
- Correct IP?
hostname -Ishows your IP - RFID registered? Check
rfidToUserin server.js
See SETUP.md for more troubleshooting help.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- CampusCycle Team - Srishanth-023
- Built with Express.js and React Native
- Expo for mobile development tools
- Inspired by modern bike-sharing platforms
For detailed setup instructions, see SETUP.md
For issues, please open a GitHub issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Screenshots if applicable
Made with β€οΈ for college students who need wheels! π²