A comprehensive, privacy-first mobile web application for collecting anonymized travel data in Kerala, India, as part of transportation research conducted by NATPAC (National Transportation Planning and Research Centre). Built with modern web technologies and government-grade security standards.
π Full Documentation Index - Start here for complete guides // ReadMe file
| Quick Links | Description |
|---|---|
| π Quick Start | Get up and running in 5 minutes |
| π± Live Demo | Try the application |
| π§ API Docs | Complete API reference |
| ποΈ Architecture | System architecture overview |
| π‘οΈ Security | Privacy and security details |
| π§ͺ Testing | Testing strategy and setup |
graph TB
subgraph "Frontend Layer"
A[React 18 App] --> B[Vite Build Tool]
A --> C[Tailwind CSS]
A --> D[React Router]
end
subgraph "Backend Layer"
E[Express.js API] --> F[TypeScript]
E --> G[Prisma ORM]
G --> H[SQLite/MongoDB]
end
subgraph "Security Layer"
I[JWT Auth] --> J[Rate Limiting]
J --> K[Data Anonymization]
K --> L[GDPR Compliance]
end
subgraph "Mobile Integration"
M[iOS Swift Bridge] --> N[Native Location]
O[Android Kotlin] --> N
P[PWA Features] --> N
end
A --> E
E --> I
A --> M
A --> O
A --> P
style A fill:#61dafb,stroke:#333
style E fill:#68a063,stroke:#333
style H fill:#336791,stroke:#333
style L fill:#e74c3c,stroke:#333
- React 18: Modern React with hooks and concurrent rendering
- Vite: Lightning-fast development server and optimized builds
- Tailwind CSS: Utility-first CSS with custom design system
- React Router: Client-side routing with protected routes
- PWA: Progressive Web App with offline capabilities
- Node.js 18+: JavaScript runtime with ES2022 support
- TypeScript: Type-safe development with strict mode
- Express.js: Web framework with comprehensive middleware
- Prisma: Type-safe ORM with database migrations
- JWT: Stateless authentication with refresh tokens
- SQLite: Development database with file-based storage
- MongoDB: Production database with cloud scalability
- Prisma Schema: Database modeling with automatic migrations
- Swift Bridge: iOS native location and haptic integration
- Kotlin Bridge: Android location services and notifications
- WebView: Hybrid app wrapper for native deployment
- Node.js 18+: Download here
- Git: Download here
- Code Editor: VS Code recommended
# Clone the repository
git clone https://github.com/your-org/traveal.git
cd traveal
# Install all dependencies
npm install # Frontend dependencies
cd backend && npm install # Backend dependencies
cd .. # Return to rootcd backend
cp .env.example .env
# Edit .env with your configurationKey environment variables:
NODE_ENV=development
PORT=3001
DATABASE_URL="file:./dev.db"
JWT_SECRET="your-super-secret-jwt-key"
JWT_REFRESH_SECRET="your-super-secret-refresh-key"
CORS_ORIGIN="http://localhost:5173"
# πΊοΈ MAPS API CONFIGURATION (IMPORTANT!)
# For route monitoring and safety features, configure maps API keys:
# See MAPS_API_CONFIGURATION.md for detailed setup instructions
# Google Maps API Key (get from https://console.cloud.google.com/)
GOOGLE_MAPS_API_KEY=your_google_maps_api_key_here
# MapMyIndia API Key (get from https://www.mapmyindia.com/api/)
MAPMYINDIA_API_KEY=your_mapmyindia_api_key_here
MAPMYINDIA_CLIENT_ID=your_mapmyindia_client_id_here
# Map provider settings
DEFAULT_MAP_PROVIDER=google
MAP_GEOCODING_ENABLED=true
MAP_ROUTING_ENABLED=true
# π¨ SOS & SAFETY FEATURES
# Emergency notification settings (for route deviation detection)
SMS_SERVICE_API_KEY=your_twilio_api_key_here
EMAIL_SERVICE_API_KEY=your_sendgrid_api_key_here
EMERGENCY_PHONE_NUMBERS_DEFAULT=911π Maps API Setup Required: For maps functionality and SOS route monitoring, you need to configure Google Maps and/or MapMyIndia API keys. See
MAPS_API_CONFIGURATION.mdfor detailed API setup instructions andSOS_ROUTE_MONITORING.mdfor safety feature configuration.
# In root directory, create .env
echo "VITE_API_URL=http://localhost:3001/api/v1" > .envcd backend
# Generate Prisma client
npx prisma generate
# Create and migrate database
npx prisma db push
# (Optional) Explore database
npx prisma studio# Option 1: Start servers separately (recommended for debugging)
# Terminal 1: Backend
cd backend
npm run dev # Runs on http://localhost:3001
# Terminal 2: Frontend (new terminal)
npm run dev # Runs on http://localhost:5173
# Option 2: Start both servers concurrently
npm run dev:all # Starts both frontend and backend| Service | URL | Status |
|---|---|---|
| π¨ Frontend | http://localhost:5173 | Interactive app |
| βοΈ Backend API | http://localhost:3001/health | JSON health check |
| π API Docs | http://localhost:3001/docs | Interactive documentation |
| ποΈ Database Studio | http://localhost:5555 | Visual database browser |
Success Indicators:
- β Frontend shows onboarding welcome screen
- β
Backend health endpoint returns
{"status": "healthy"} - β No console errors in browser or terminal
- Xcode 12+
- iOS 14+
- Swift 5+
- Add LocationBridge.swift to your iOS project
- Configure Info.plist permissions:
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs location access to track your trips.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs background location access for automatic trip detection.</string>- Enable background location updates in project capabilities
// In your WebView setup
let locationBridge = LocationBridge()
webView.configuration.userContentController.add(locationBridge, name: "LocationBridge")- Android SDK 21+
- Kotlin support
- React Native (optional)
- Add LocationBridge.kt to your Android project
- Configure AndroidManifest.xml permissions:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />// In your Activity
val locationBridge = LocationBridge(reactContext)
// Register with your WebView or React Native bridgePOST /api/v1/auth/register- Register anonymous userPOST /api/v1/auth/login- Login with device IDGET /api/v1/auth/me- Get user profilePUT /api/v1/auth/consent- Update consent preferencesDELETE /api/v1/auth/account- Delete account (GDPR)
POST /api/v1/trips- Create new tripGET /api/v1/trips- Get user trips (paginated)GET /api/v1/trips/active- Get current active tripPUT /api/v1/trips/:id- Update trip detailsPOST /api/v1/trips/:id/locations- Add location point
GET /api/v1/maps/provider- Get current map providerPOST /api/v1/maps/provider- Set map provider (Google/MapMyIndia)GET /api/v1/maps/geocode- Convert address to coordinatesGET /api/v1/maps/reverse-geocode- Convert coordinates to addressGET /api/v1/maps/autocomplete- Get place suggestionsPOST /api/v1/maps/route- Calculate routes between pointsPOST /api/v1/maps/static-map- Generate static map images
POST /api/v1/sos/profile- Create/update SOS emergency profileGET /api/v1/sos/profile- Get SOS profile settingsPOST /api/v1/sos/monitoring/start- Start route monitoring for tripPOST /api/v1/sos/monitoring/update-location- Update location and check deviationPOST /api/v1/sos/monitoring/end/:id- End route monitoringPOST /api/v1/sos/alert/trigger- Trigger emergency alertPOST /api/v1/sos/alert/verify-password- Verify emergency passwordGET /api/v1/sos/alerts/active- Get active emergency alerts
- π¨ Modern UI: Clean, government-approved design with dark mode
- π± Mobile-First: Optimized for smartphones with touch interactions
- β‘ Progressive Web App: Install on any device, works offline
- β¨ Smooth Animations: 60fps micro-interactions and transitions
- βΏ Accessibility: WCAG 2.1 AA compliant with screen reader support
- π± Responsive Design: Automatically adjusts to any screen size
- π Anonymous by Design: No personal data collection, anonymous UUIDs only
- π‘οΈ GDPR Compliant: Full European privacy regulation compliance
- π Encryption: AES-256 encryption for all sensitive data
- π Granular Consent: User controls exactly what data is shared
- β° Auto-Anonymization: Location data anonymized after 30 days
- ποΈ Right to Deletion: Complete account and data removal
- π Automatic Detection: Smart trip detection using device sensors
- βοΈ Manual Entry: User-initiated trip logging with validation
- πΊοΈ Route Tracking: GPS-based route recording with accuracy control
- π Trip Validation: Government compliance verification
- π Analytics: Personal trip statistics and insights
- π Dual Provider Support: Google Maps and MapMyIndia integration
- πΊοΈ Route Calculation: Real-time route optimization and planning
- π Geocoding Services: Address-to-coordinates conversion
- π Place Search: Autocomplete suggestions and place details
- πΊοΈ Static Maps: Generate map images with markers and routes
- π΄ Emergency Alerts: Instant emergency contact notification system
- πΊοΈ Route Deviation Detection: Real-time monitoring for safety
- π± Multi-Channel Notifications: SMS, Email, and Push notifications
- π Stealth Mode: Discreet emergency alerts with partial passwords
- π Grace Period: Smart false-alarm prevention system
- π‘ Live Location Sharing: Real-time location updates during emergencies
- π Achievement System: Unlockable badges for milestones
- π Weekly Challenges: Engaging tasks to encourage participation
- π Leaderboards: Anonymous competition and motivation
- π° Points System: Reward mechanism for app engagement
- π Real-time Updates: WebSocket-based live notifications
- π± Push Notifications: Background updates with user permission
- π Achievement Alerts: Celebratory notifications for milestones
- πΆ System Status: Network connectivity and sync indicators
- Fluid Containers: Dynamically adjusts container width based on screen size
- Flexible Grids: CSS Grid and Flexbox layouts that adapt to any viewport
- Breakpoint Optimization: Custom breakpoints for all device categories:
- Small phones (320px - 359px)
- Medium phones (360px - 413px)
- Large phones (414px - 639px)
- Tablets (640px - 1023px)
- Desktops (1024px+)
- Fluid Typography: Font sizes that scale proportionally with viewport width
- Responsive Spacing: Padding, margin, and gap utilities that adapt to screen size
- Touch Target Optimization: Minimum 44px touch targets on mobile devices
- Safe Area Support: Proper handling of notches and home indicators on modern devices
- Consistent Components: All UI components automatically adjust to screen size
- Dynamic Shadows: Depth effects that adapt to device capabilities
- Color Scheme Adaptation: Automatic light/dark mode based on system preferences
- High DPI Support: Crisp visuals on retina and high-resolution displays
- Adaptive Bottom Navigation: Mobile-friendly bottom navigation that disappears on larger screens
- Contextual Header: Page titles in header on mobile, persistent navigation on desktop
- Swipe Gestures: Touch-friendly navigation for mobile users
- Keyboard Navigation: Full keyboard support for accessibility
- Conditional Rendering: Components only render what's needed for the current screen size
- Lazy Loading: Non-critical assets loaded only when needed
- Memory Management: Efficient resource usage across all device types
- Battery Optimization: Reduced animations and effects on battery-constrained devices
- Location fuzzing within 100m radius
- Time rounding to nearest hour
- Automatic personal data removal after 90 days
- Government-grade anonymization standards
- JWT authentication with refresh tokens
- Rate limiting and request validation
- CORS protection and security headers
- Input sanitization and SQL injection prevention
- Device-based anonymous identification
- Explicit opt-in consent management
- Right to data deletion
- Data portability and export
- Transparent data usage policies
- Automatic data retention management
cd backend
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage reportnpm test # Run frontend tests
npm run test:e2e # End-to-end tests# Build for production
npm run build
cd backend && npm run build
# Deploy with PM2
npm install -g pm2
pm2 start backend/dist/app.js --name traveal-api
# Serve frontend with nginx
sudo cp -r dist/* /var/www/html/Vercel (Frontend):
npm install -g vercel
vercel --prodRailway (Backend):
railway login
railway upHeroku (Full Stack):
heroku create traveal-app
git push heroku main- Health Checks: Automated endpoint monitoring
- Error Tracking: Real-time error reporting with Sentry
- Performance: Core Web Vitals and API response times
- Usage Analytics: Privacy-compliant user behavior insights
# GitHub Actions workflow
name: Deploy Production
on:
push:
branches: [main]
jobs:
test-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Run Tests
run: |
npm test -- --coverage
cd backend && npm test
- name: Deploy to Production
run: |
npm run build
# Deploy commands# Server
NODE_ENV=production
PORT=3001
# Database
DATABASE_URL="mongodb://localhost:27017/traveal"
# Authentication
JWT_SECRET="your-production-jwt-secret"
JWT_REFRESH_SECRET="your-production-refresh-secret"
JWT_EXPIRES_IN="15m"
JWT_REFRESH_EXPIRES_IN="7d"
# Security
BCRYPT_ROUNDS=12
CORS_ORIGIN="https://your-domain.com"
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100
# Privacy
ANONYMIZATION_RADIUS=100
TIME_ROUNDING_MINUTES=60
# Notifications (optional)
FCM_SERVER_KEY="your-firebase-server-key"VITE_API_URL=https://your-api-domain.com/api/v1
VITE_APP_NAME="Traveal"
VITE_APP_VERSION="1.0.0"Traveal/
βββ src/ # Frontend React application
β βββ components/ # React components
β β βββ onboarding/ # User onboarding flow
β β βββ trip/ # Trip management components
β β βββ notifications/ # Notification system
β β βββ settings/ # User settings
β β βββ shared/ # Shared/utility components
β βββ pages/ # Route pages
β βββ services/ # API and business logic
β β βββ api.js # Backend integration
β βββ utils/ # Utility functions
βββ backend/ # Node.js backend API
β βββ src/
β β βββ controllers/ # Request handlers
β β βββ services/ # Business logic
β β βββ middleware/ # Express middleware
β β βββ models/ # Data models
β β βββ routes/ # API routes
β β βββ config/ # Configuration
β β βββ utils/ # Utility functions
β βββ prisma/ # Database schema
β βββ tests/ # Backend tests
βββ mobile/ # Mobile platform bridges
β βββ ios/ # Swift iOS integration
β βββ android/ # Kotlin Android integration
βββ docs/ # Documentation
βββ README.md # This file
- Fork & Clone: Fork the repo and clone your fork
- Branch: Create feature branch:
git checkout -b feature/amazing-feature - Develop: Make changes following our coding standards
- Test: Ensure all tests pass:
npm test && cd backend && npm test - Document: Update relevant documentation
- Submit: Create pull request with clear description
- TypeScript: Use TypeScript for all backend code
- React Best Practices: Functional components with hooks
- Testing: Write tests for new features (target 80%+ coverage)
- Privacy by Design: Follow GDPR and privacy principles
- Mobile-First: Ensure responsive design on all screen sizes
- No Personal Data: Never log or store personally identifiable information
- Data Anonymization: Implement anonymization before data storage
- Consent First: All data collection requires explicit user consent
- Secure by Default: Use encryption and secure communication
When contributing, update relevant documentation:
- API changes β Update API docs
- Component changes β Update Component docs
- Security changes β Update Privacy docs
- New features β Add tests per Testing guide
- π Complete Docs: Full documentation index
- π§ API Reference: Detailed API documentation
- ποΈ Architecture: System design and components
- π Security Guide: Privacy and security details
- βοΈ Deployment: Setup and deployment guide
- π§ͺ Testing: Testing strategies and examples
- πΊοΈ Maps API Setup: Maps API configuration guide
- π¨ SOS & Route Monitoring: Safety features and route deviation detection
- Demo App: https://traveal-demo.natpac.gov.in
- API Playground: https://api.traveal.gov.in/docs
- Status Page: https://status.traveal.gov.in
- GitHub Issues: Report bugs and request features
- π Bug Reports: Create detailed GitHub issue
- β Questions: Check docs first, then create discussion
- π‘οΈ Security Issues: Email [email protected]
- π Direct Support: Contact development team
- NATPAC: National Transportation Planning and Research Centre
- Government of Kerala: Transportation research initiative
- Open Source Community: React, Node.js, and countless other projects
- Contributors: All developers who have contributed to this project
Built with β€οΈ for sustainable transportation research in Kerala