A full-stack web application for tracking public buses in real-time, designed for small cities.
A full-stack web application for tracking public buses in real-time, designed for small cities.
busbeacon/
├── backend/
│ ├── server.js
│ ├── routes/
│ │ └── api.js
│ ├── data/
│ │ └── mockData.js
│ ├── services/
│ │ └── busSimulator.js
│ ├── package.json
│ └── .env
├── frontend/
│ ├── public/
│ │ └── index.html
│ ├── src/
│ │ ├── App.js
│ │ ├── index.js
│ │ ├── components/
│ │ │ ├── Home.js
│ │ │ ├── LiveTracking.js
│ │ │ ├── Stops.js
│ │ │ ├── Settings.js
│ │ │ ├── Navigation.js
│ │ │ └── Map.js
│ │ ├── styles/
│ │ │ └── App.css
│ │ └── services/
│ │ └── api.js
│ └── package.json
├── admin/
│ ├── public/
│ │ └── index.html
│ ├── src/
│ │ ├── App.js
│ │ ├── index.js
│ │ └── styles/
│ │ └── App.css
│ └── package.json
└── README.md
- Backend: Node.js, Express.js
- Frontend: React.js, Leaflet (maps), Axios
- Admin Panel: React.js
- Data: Simulated mock data (no database required for demo)
- Node.js (v14 or higher)
- npm or yarn
- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Start the server:
npm startThe backend server will run on http://localhost:5000
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the React app:
npm startThe frontend will run on http://localhost:3000
- Navigate to the admin directory:
cd admin- Install dependencies:
npm install- Start the admin panel:
npm startThe admin panel will run on http://localhost:3001
- Real-time bus tracking on interactive map
- Nearest stop detection with live ETAs
- Bus route visualization
- Search functionality for buses and routes
- Responsive design for mobile and desktop
- View all buses and their status
- Monitor bus locations in real-time
- Track which buses are in service
GET /api/routes- Get all bus routesGET /api/buses- Get all buses with current locationsGET /api/buses/:id- Get specific bus detailsGET /api/stops/nearby?lat=...&lon=...- Get nearest stop and ETAs
The application simulates a fictional city called "Maple Creek" with:
- 4 bus routes (Downtown Express, University Loop, Mall Shuttle, Hospital Line)
- 6 buses in operation
- 50+ bus stops across the city
- Real-time position updates every 5 seconds
- Start all three applications (backend, frontend, admin)
- Open the frontend in your browser
- The map will show buses moving in real-time
- Click on a bus to see detailed tracking
- Use the search bar to find specific routes
- Open the admin panel in a separate window to show the authority view
- The simulation runs automatically when the backend starts
- Bus positions update every 5 seconds
- ETAs are calculated based on distance and average speed
- All data is stored in memory (resets on server restart)
- No actual GPS data or database required
This is a demonstration prototype for educational purposes.