A full-stack web application that connects users to nearby ambulances and hospitals in real time. Built with HTML, CSS, JavaScript (frontend) and Node.js, Express, MongoDB (backend).
| Feature | Description |
|---|---|
| Emergency Call | One-click ambulance dispatch with 8-second confirmation timer |
| Real-Time Tracking | Live ambulance location updates via GPS |
| Nearby Hospitals | Search and display hospitals by name or area with call integration |
| Role-Based Dashboards | Separate views for User, Hospital, and Driver |
| Driver Availability | Drivers toggle ON/OFF duty status with live map |
| Google Auth | Firebase-powered Google Sign-In |
| SOS Alert | Emergency SOS page with direct call access |
| Dark Mode | Persistent theme across sessions |
| PWA Support | Service worker + manifest for installable experience |
| Feedback System | In-app user feedback form |
Frontend
- HTML5, CSS3, Vanilla JavaScript
- Google Maps JavaScript API (Places, Geolocation)
- Firebase Authentication (Google Sign-In)
- Font Awesome icons
Backend
- Node.js + Express.js
- MongoDB + Mongoose
- bcryptjs (password hashing)
- jsonwebtoken (JWT auth)
- dotenv (environment variable management)
AmbuFlow/
├── index.html # Landing page (entry point)
├── login.html # Login & signup
├── roles.html # Role selection (User / Hospital / Driver)
├── nearby.html # Find nearby hospitals
├── sos.html # SOS emergency page
├── feedback.html # User feedback
├── features.html # Feature showcase
├── team.html # Team page
├── contact.html # Contact & support
├── about.html # About page
├── driver.html # Driver dashboard
├── hospital.html # Hospital dashboard
├── manage.html # Ambulance management
├── profile.html # User profile
│
├── src/css/ # Scoped CSS per page
│ ├── navbar.css
│ ├── index.css
│ ├── login.css
│ ├── driver.css
│ ├── hospital.css
│ └── ...
│
├── images/ # All project images and assets
│
├── script.js # Shared frontend logic (dark mode, accordion, nav)
├── scripts.js # Service worker registration
├── firebase.js # Firebase Google Auth
│
└── backend/ # Node.js REST API
├── server.js # Express server entry point
├── .env.example # Environment variable template
├── Controllers/
│ └── ambulanceController.js
└── Models/
├── User.js
└── Ambulance.js
- Node.js v18 or higher
- MongoDB Atlas account (free tier works)
- Google Maps API key (get one here)
- Firebase project (set up here)
git clone https://github.com/YOUR_USERNAME/AmbuFlow.git
cd AmbuFlowcd backend
npm installCreate your environment file:
cp .env.example .envOpen backend/.env and fill in your values:
MONGODB_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/ambuflow
JWT_SECRET=your_long_random_secret_here
PORT=3000Start the backend:
# Development (auto-restart on changes)
npm run dev
# Production
npm startThe API will be running at http://localhost:3000.
Before opening the frontend, replace the placeholder API keys:
Google Maps (user.html and driver.html):
<!-- Replace YOUR_GOOGLE_MAPS_API_KEY with your actual key -->
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_GOOGLE_MAPS_API_KEY&libraries=places">Firebase (firebase.js):
const firebaseConfig = {
apiKey: "YOUR_FIREBASE_API_KEY",
authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
projectId: "YOUR_PROJECT_ID",
// ... other fields from Firebase Console
};Security note: Never commit real API keys to version control. For production, use a build tool to inject keys from environment variables.
Open index.html with a local server (required for service worker and Firebase to work):
# Using VS Code Live Server extension (recommended)
# Right-click index.html → Open with Live Server
# Or using Python
python -m http.server 8080
# Or using npx
npx serve .Navigate to http://localhost:8080.
| Method | Route | Description | Auth Required |
|---|---|---|---|
GET |
/ |
Health check | No |
POST |
/signup |
Register a new user | No |
POST |
/login |
Login, returns JWT | No |
GET |
/protected |
Protected route example | Yes (Bearer JWT) |
POST |
/ambulances/create |
Register a new ambulance | No |
GET |
/ambulances |
List all ambulances | No |
POST |
/ambulances/book |
Book an ambulance | No |
| Variable | Required | Description |
|---|---|---|
MONGODB_URI |
Yes | MongoDB Atlas connection string |
JWT_SECRET |
Yes | Secret key for JWT signing (min 32 chars) |
PORT |
No | Server port (default: 3000) |
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m "feat: add your feature" - Push the branch:
git push origin feature/your-feature - Open a Pull Request
Please read Contributing.md and CODE_OF_CONDUCT.md before contributing.