- Marcin Bator
- Wiktor Mazur
Rzeszów University of Technology, 2023
- Project Assumptions
- Implementation Agenda
- Technologies
- Front-end Implementation Details
- 4.1 Overview
- 4.2 API Communication
- Back-end Implementation Details
- 5.1 Overview
- 5.2 Endpoints (Web Layer)
- 5.3 Service (Server Layer)
- Summary
- Running locally
The project addresses a synchronization problem on a two-way road with a narrow bridge. The goal is to ensure collision-free passage for cars from both the south and north directions.
The solution is a web application accessible through a browser. It utilizes server-side code with multithreading implemented on the back-end server. Users can spawn cars, set their direction, and customize crossing times. The application is fully dockerized for easy deployment.
- React 18
- Next.js 14.0.4
- TypeScript 5
- Tailwind CSS 3.3.0
- Java 17.09
- Spring Boot 3.2
- Apache Maven
The application features a user-friendly UI allowing car addition, directional selection, and control over passing cars. It includes a visualization of cars, red/green lights, and queue status. Car crossing times are randomly generated upon addition.
Front-end communicates with the back-end API on port 8080, using standard JS fetch and await every 10 milliseconds to get car states.
The back-end utilizes Spring Boot with 6 REST endpoints, handling car addition, retrieval, direction, passing limits, and scheduled removal of processed cars.
GET('/api/cars')
: Returns the list of all cars.POST('/api/add-car')
: Adds a new car to the program.GET('/api/direction')
: Returns the current direction.GET('/api/max-cars')
: Returns the current passing limit.POST('/api/max-cars')
: Sets a new passing limit.SCHEDULED
: Deletes cars passed the bridge for at least 5 seconds.
The core class, BridgeService
, manages car queues and threading. It ensures synchronized single-car bridge crossing.
The multithreading solution in Java addresses the bridge problem. Using React and Spring Boot, the web application enhances understanding of multithreading concepts in a visual and interactive manner.
Clone repository, then open in the terminal and launch
docker-compose up
.