Skip to content

Post-Accident Alert System is a real-time emergency response platform that instantly detects accidents and broadcasts alerts to nearby hospitals and responders. It leverages WebSockets for seamless communication and REST APIs for structured data handling, ensuring quick response times and enhanced accident management.

License

Notifications You must be signed in to change notification settings

Raamprathap/Post-Accident-Alert-System-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚨 Post-Accident Alert System Backend

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.


🌟 Features

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.


🛠 Technologies Used

🚀 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


📥 Installation

1️⃣ Clone the Repository

 git clone https://github.com/your-username/raamprathap-post-accident-alert-system-backend.git
 cd raamprathap-post-accident-alert-system-backend

2️⃣ Install Dependencies

 npm install

3️⃣ Start the Server

 npm start

The server will run on PORT 3000 by default. You can configure this using the PORT environment variable.


🔌 API Endpoints

🟢 WebSocket Connection

  • WebSocket server is available at /signal

📡 REST API

  • POST /signal - Accepts JSON data to process accident alerts.

Example Usage:

curl -X POST -H "Content-Type: application/json" -d '{"type": "hospital_request", "lat": "12.3456", "lng": "78.9101"}' http://localhost:3000/signal

🔗 WebSocket Example

const 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);
};

⚙️ Configuration

  • CORS Setup: Modify server.js to allow specific origins.
  • Port Configuration: Change PORT in environment variables as needed.

🤝 Contributing

🚀 Contributions are welcome! If you want to improve the project:

  1. Fork the repository 🍴
  2. Create a new branch 🔀
  3. Make your changes ✏️
  4. Submit a pull request 📬

📜 License

This project is licensed under the ISC License. See the LICENSE file for details.


Authors


💡 Built with passion by Raamp and akshayks13 🚀

About

Post-Accident Alert System is a real-time emergency response platform that instantly detects accidents and broadcasts alerts to nearby hospitals and responders. It leverages WebSockets for seamless communication and REST APIs for structured data handling, ensuring quick response times and enhanced accident management.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •