This repository contains the backend server for a Post-Accident Alert System, designed to facilitate real-time communication and emergency response coordination using WebSockets and REST APIs.
✅ Real-time Communication: Uses WebSockets for instant data exchange between clients.
✅ REST API Support: Handles HTTP requests to process alert signals.
✅ CORS Configuration: Enables cross-origin communication.
✅ Hospital Nearest Location Finder: Identifies and broadcasts the nearest hospital based on accident location.
✅ WebSocket Broadcast: Sends emergency data to all connected clients.
🚀 Node.js – Server-side JavaScript runtime
🚀 Express.js – Lightweight web framework
🚀 WebSocket (ws) – Handles real-time bi-directional communication
🚀 Body-Parser – Parses incoming request bodies
🚀 CORS – Enables cross-origin resource sharing
git clone https://github.com/your-username/raamprathap-post-accident-alert-system-backend.git
cd raamprathap-post-accident-alert-system-backend npm install npm startThe server will run on PORT 3000 by default. You can configure this using the PORT environment variable.
- WebSocket server is available at
/signal
- POST /signal - Accepts JSON data to process accident alerts.
curl -X POST -H "Content-Type: application/json" -d '{"type": "hospital_request", "lat": "12.3456", "lng": "78.9101"}' http://localhost:3000/signalconst ws = new WebSocket('ws://localhost:3000');
ws.onopen = function () {
console.log('✅ WebSocket connection established.');
ws.send(JSON.stringify({ type: 'hospital_request', lat: 12.3456, lng: 78.9101 }));
};
ws.onmessage = function (event) {
console.log('📩 Message received:', event.data);
};- CORS Setup: Modify
server.jsto allow specific origins. - Port Configuration: Change
PORTin environment variables as needed.
🚀 Contributions are welcome! If you want to improve the project:
- Fork the repository 🍴
- Create a new branch 🔀
- Make your changes ✏️
- Submit a pull request 📬
This project is licensed under the ISC License. See the LICENSE file for details.
-
👤 Raam Prathap
📧 Email: raamprathap17242@gmail.com
🔗 GitHub: Raam Prathap -
👤 Akshay KS
📧 Email: akshayks1005@gmail.com
🔗 GitHub: Akshay KS
💡 Built with passion by Raamp and akshayks13 🚀