Speedometer is a web application in which the sensor speed data are inserted into the database and at the same time we can show that speed data on the UI.
The speedometer consists of three main components: frontend, backend, and database.
- The frontend is developed using React.js, enabling efficient state management and real-time data rendering. It establishes a WebSocket connection with the backend to fetch live speed updates and renders them dynamically on a visually appealing UI.
- Frontend Technologies: JavaScript, React.js, Tailwind CSS
- The backend is implemented with Node.js and Express.js, and a WebSocket server for real-time data communication. It handles data generation, storage, and broadcasting to the frontend efficiently.
- Backend Technologies: JavaScript, Node.js, Express, WebSocket
- The backend generates speed data, inserts it into the database, and displays it on the UI. The data can also be collected from sensors and inserted into the database.
- The application utilizes PostgreSQL, a powerful relational database management system (RDBMS), to store sensor speed data securely. The database is optimized for real-time reads and writes, ensuring smooth and reliable performance.
Docker repository: - https://hub.docker.com/repository/docker/luxprajapati/speedometer/general
-
Clone the repository from GitHub:
git clone <repository-url>
-
Open Docker Desktop and pull the images from Docker Hub:
docker pull luxprajapati/speedometer:frontend docker pull luxprajapati/speedometer:backend
-
Update the
DATABASE_URL
in thedocker-compose.yml
file to your database URL and the PostgreSQL environment variables to your credentials.DATABASE_URL= postgresql://Your_username:Your_password@postgres:5432/Your_DB_Name
-
Compose the cloned project:
docker-compose up -d
-
After successfully composing, go to: http://localhost:80
-
To check the backend logs, go to Docker Desktop, navigate to the container section, and view the backend logs.
-
To check the PostgreSQL database:
docker exec -it <postgres_container_id> bash psql -U postgres -d speedometer_DB \dt SELECT * FROM speed_data;
- Ensure pgAdmin 4 is installed on your local system.
-
Go to the
speedometer-app
directory and install the npm packages:npm install
-
Go to the
server
directory and install the npm packages:npm install
-
Add a
.env
file in yourserver
folder with the following content:PORT=5000 DATABASE_URL=postgresql://your-user-name:your-pgadmin-4-password@localhost:5432/database-name-you-created
-
Open pgAdmin 4 and create a new database.
-
Run the backend and frontend:
# In the server directory npm run dev # In the speedometer-app directory npm start