`Direct Driver-to-Passenger Connection β’ No Middleman β’ Lower Fees β’ Faster Service`
- Technology Stack
- Features
- Installation
- Usage Guide
- Architecture
- P2P Communication
- Contributing
- Call π€
- License
Tools
- Frontend: HTML5, CSS3, JavaScript (ES6+)
- Maps: Leaflet.js for interactive maps
- P2P Communication: PeerJS (WebRTC)
- Geolocation: Browser Geolocation API
- UI Framework: Custom CSS with responsive design
- Icons: Font Awesome
- Animation: CSS3 Animations
Key Features
- Dynamic skyline with moving buildings
- Animated cars with passengers
- Data packet visualization showing P2P connections
- Location pins representing drivers and passengers
- Optional video background of a city at night
- Passenger: Search for nearby drivers and request rides
- Driver: Register vehicle information and accept ride requests
- Full Name
- Car Type
- Car Color
- City
- Location (latitude and longitude) automatically detected
- Option to remember driver information for future sessions
- Real-time location tracking on a map
- Online/offline status toggle
- Ride request notifications
- Daily earnings statistics
- Completed rides counter
- Driver rating
- Identifies them in the system
- Can be shared with drivers for direct connection
- Expires after 5 minutes for security
- Can be reset if needed
- View nearby drivers on a map
- See driver details (name, vehicle, rating)
- View estimated distance and arrival time
- Select a driver to request a ride
- Distinguish between real P2P drivers and simulated drivers
- Entering the driver's code to start the ride
- Verification of the code's validity
- Secure connection establishment between driver and passenger
- Real-time map shows current location and route
- Live fare calculation based on distance and time
- Driver information display
- Option to end the ride
- Detailed fare breakdown (base fare, distance charge, time charge)
- Total distance traveled
- Total time elapsed
- Option to share ride details
- Option to start a new ride
Prerequisites
- Modern web browser with JavaScript enabled
- Internet connection for map tiles and P2P communication
Local Setup
- Clone the repository:
git clone https://github.com/natty4/freepeerX.git
cd freepeerx
- Open the project in a web server. You can use any of these methods:
Using Python:
# Python 3
python -m http.server 8000
# Python 2
python -m SimpleHTTPServer 8000
Using Node.js:
# Install http-server if you haven't already
npm install -g http-server
# Run the server
http-server -p 8000
- Open your browser and navigate to
http://localhost:8000
For Passengers
- Click "Get Started" on the landing page
- Select "Passenger"
- Note your unique code (you can share this with a specific driver if desired)
- Click "Find a Driver"
- Browse available drivers on the map
- Click on a driver card to select them
- For real P2P drivers, a ride request will be sent automatically
- For simulated drivers, you'll proceed directly to the pairing screen
- Enter the 6-digit code provided by the driver
- Click "Verify & Start Ride"
- Monitor your route on the map
- Watch the fare calculation in real-time
- Click "End Ride" when you reach your destination
- Review the fare breakdown
- Share ride details if desired
- Start a new ride or exit the application
For Drivers
- Click "Get Started" on the landing page
- Select "Driver"
- Fill in your details in the registration form
- Check "Remember Me" if you want to save your information
- Click "Register"
- Use the "Online/Offline" toggle to control your availability
- When online, your location will be broadcast to nearby passengers
- Ride requests will appear in your dashboard
- Review passenger details and distance
- Accept or decline the request
- If accepted, note the generated code to share with the passenger
- Monitor your route on the map
- The fare is calculated automatically based on distance and time
- The ride ends when the passenger clicks "End Ride"
- Your earnings will be updated in your dashboard
FreePeerX is built with a modular architecture that separates concerns into distinct classes:
Core Components
- P2PCommunicationManager: Handles all peer-to-peer communication using PeerJS
- DriverRegistration: Manages driver information and online status
- LocationTracker: Tracks and records user location using the Geolocation API
- FareCalculator: Calculates ride fares based on distance and time
- CodeManager: Generates and verifies unique codes for ride pairing
- DriversManager: Manages driver discovery and selection
- MapManager: Handles map initialization, markers, and routes
FreePeerX uses WebRTC (via PeerJS) for direct peer-to-peer communication between drivers and passengers:
How P2P Works
- Peer Creation: Each user creates a unique peer ID when they join the network
- Discovery: Drivers register with a discovery service (simulated in this demo)
- Connection: Passengers connect directly to drivers using their peer IDs
- Data Exchange: Location updates and ride requests are sent directly between peers
- Fallback: If P2P connection fails, the app falls back to simulated drivers
Security Features
- Unique 6-digit codes for ride verification
- Code expiration after 5 minutes
- Secure WebRTC data channels with encryption
Project Structure
The project is organized into the following structure:
freepeerx/
βββ index.html # Main HTML file
βββ styles.css # CSS styles
βββ js/
β βββ app.js # Main JavaScript file with all functionality
βββ assets/ # Images and other assets
βββ README.md # Project documentation
Local Development
- Make changes to the HTML, CSS, or JavaScript files
- Refresh your browser to see changes
Testing P2P Functionality
- Open two browser windows to simulate a driver and passenger
- Register as a driver in one window
- Connect as a passenger in the other window
Simulated Mode
- Set
CONFIG.p2p.enabled = falsein app.js to use simulated drivers - This is useful for testing without a second device
Contributions are welcome! Here's how you can contribute:
How to Contribute
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Use ES6+ features where appropriate
- Follow the existing modular pattern
- Add comments for complex logic
- Test P2P functionality thoroughly
Reporting Issues
If you encounter any bugs or issues, please open an issue on GitHub. Include the following information:
- Steps to reproduce
- Expected behavior
- Actual behavior
- Screenshots (if applicable)
- Browser and OS information
If you're interested in contributing to the project, please feel free to reach out. I'm looking for collaborators who are passionate about P2P technology and want to help build a better ride-hailing experience as well the P2P communication. Whether you're a developer, designer, or just someone with great ideas, your input is welcome!
This project is a proof of concept and is not intended for production use. It highlights the potential of P2P technology in the ride-hailing industry. The app is fully built using V0. I just added some features and modified the code a little bit. While the full P2P communication is still in progress (no worries, the app works with simulated drivers for now), so I continue working on and refining this functionality. The app is fully functional and can be used to demonstrate the concept of P2P ride-hailing.
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.