A full-stack web application built with a Rails backend and a React frontend to manage and analyze traffic data.
The Traffic Data App follows a microservices-like architecture using Docker to containerize the backend, frontend, and database services. The application consists of:
- Backend (Rails API): Manages business logic, authentication, and database interactions.
- Frontend (React App): Provides an interactive user interface for managing traffic data.
- Database (PostgreSQL): Stores and retrieves traffic data efficiently.
- Docker & Docker Compose: Used to containerize and orchestrate the services.
Each service runs in its own container, ensuring modularity and scalability.
git clone https://github.com/HunzalaMalik/traffic-data-app.git
cd traffic-data-appEnsure you have Docker Desktop installed:
- Download Docker Desktop
- Install and start Docker Desktop
Check if Docker is running with:
docker infoIf this command returns details about Docker, it is running. If not, start Docker Desktop.
./setup.shThis script will:
- Check if Docker is installed and running
- Check and install Docker Compose if missing
- Stop and remove any running containers
- Create a Docker network (
traffic_network) - Build and start backend, frontend, and database containers using
docker-compose up -d --build - Verify running services using
docker ps - Provide application access URLs
Once setup is complete, you can access:
- Backend API: http://localhost:3001
- Frontend App: http://localhost:3000
The Traffic Data App provides the following API endpoints:
http://localhost:3001/api/v1/
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/country_traffics |
Retrieve all country traffic data |
| POST | /api/v1/country_traffics |
Create a new country traffic entry |
| GET | /api/v1/country_traffics/:id |
Retrieve a specific country traffic entry |
| PATCH | /api/v1/country_traffics/:id |
Update a country traffic entry |
| DELETE | /api/v1/country_traffics/:id |
Delete a country traffic entry |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/country_traffics/:country_traffic_id/vehicle_type_traffics |
Retrieve all vehicle type traffic data for a country |
| POST | /api/v1/country_traffics/:country_traffic_id/vehicle_type_traffics |
Create a new vehicle type traffic entry |
| GET | /api/v1/country_traffics/:country_traffic_id/vehicle_type_traffics/:id |
Retrieve a specific vehicle type traffic entry |
| PATCH | /api/v1/country_traffics/:country_traffic_id/vehicle_type_traffics/:id |
Update a vehicle type traffic entry |
| DELETE | /api/v1/country_traffics/:country_traffic_id/vehicle_type_traffics/:id |
Delete a vehicle type traffic entry |
- To stop the application:
docker-compose down
- To restart the application after changes:
docker-compose up -d --build