Skip to content

Commit a2fe59c

Browse files
authored
Merge pull request #6 from Meikelele/feature/web
[feature/web] update README
2 parents 066bebd + 7188966 commit a2fe59c

5 files changed

Lines changed: 127 additions & 19 deletions

File tree

README.md

Lines changed: 111 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ The system dynamically selects traffic light phases based on current traffic dem
1313

1414
- [Project Goal](#project-goal)
1515
- [Tech Stack](#tech-stack)
16+
- [Architecture](#architecture)
1617
- [Installation](#installation)
18+
- [Running Web App](#running-web-app)
1719
- [Input Format](#input-format)
1820
- [Output Format](#output-format)
1921
- [Intersection Model](#intersection-model)
2022
- [Traffic Control Algorithm](#traffic-control-algorithm)
2123
- [Example Simulation](#example-simulation)
24+
- [Web Visualization](#web-visualization)
2225
- [Project Assumptions](#project-assumptions)
2326
- [Design Decisions](#design-decisions)
2427
- [Tests](#tests)
25-
- [Possible Improvements](#possible-improvements)
28+
- [Continuous Integration](#continuous-integration)
2629

2730
---
2831

@@ -44,17 +47,52 @@ The output of the simulation is a JSON file containing vehicles that left the in
4447

4548
---
4649

50+
[//]: # (# Tech Stack)
51+
52+
[//]: # (![Java17](https://img.shields.io/badge/-Java17-ffffff?style=flat-square&logo=openjdk&logoColor=000000))
53+
54+
[//]: # (![Maven](https://img.shields.io/badge/-ApacheMaven-C71A36?style=flat-square&logo=apachemaven&logoColor=000000))
55+
56+
[//]: # (![Jackson](https://img.shields.io/badge/-JacksonDatabind-FF9900?style=flat-square))
57+
58+
[//]: # (![JUnit5](https://img.shields.io/badge/-JUnit5-25A162?style=flat-square&logo=junit5&logoColor=000000))
59+
4760
# Tech Stack
4861

49-
![Java17](https://img.shields.io/badge/-Java17-ffffff?style=flat-square&logo=openjdk&logoColor=000000)
50-
![Maven](https://img.shields.io/badge/-ApacheMaven-C71A36?style=flat-square&logo=apachemaven&logoColor=000000)
51-
![Jackson](https://img.shields.io/badge/-JacksonDatabind-FF9900?style=flat-square)
52-
![JUnit5](https://img.shields.io/badge/-JUnit5-25A162?style=flat-square&logo=junit5&logoColor=000000)
62+
### Backend
63+
64+
![Java17](https://img.shields.io/badge/Java-17-orange?logo=openjdk)
65+
![SpringBoot](https://img.shields.io/badge/SpringBoot-3.x-green?logo=springboot)
66+
![Maven](https://img.shields.io/badge/ApacheMaven-C71A36?logo=apachemaven)
67+
![Jackson](https://img.shields.io/badge/Jackson-JSON-blue)
68+
69+
### Frontend
70+
71+
![Angular](https://img.shields.io/badge/Angular-17-red?logo=angular)
72+
![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue?logo=typescript)
73+
![RxJS](https://img.shields.io/badge/RxJS-reactive-purple)
74+
![SVG](https://img.shields.io/badge/SVG-Visualization-orange)
75+
76+
### Testing
77+
78+
![JUnit5](https://img.shields.io/badge/JUnit5-testing-green?logo=junit5)
79+
![Jasmine](https://img.shields.io/badge/Jasmine-tests-pink)
80+
![Karma](https://img.shields.io/badge/Karma-test_runner-yellow)
81+
82+
### CI
83+
84+
![GitHubActions](https://img.shields.io/badge/GitHubActions-CI-blue?logo=githubactions)
5385

54-
Project modules:
86+
87+
88+
# Architecture
89+
90+
The project is organized into several modules to keep responsibilities clearly separated.
5591

5692
- **engine** – simulation logic and traffic control algorithm
5793
- **cli** – command line interface for running the simulation
94+
- **server** – Spring Boot backend exposing the simulation as a REST API
95+
- **web** – Angular frontend visualizing the intersection and simulation steps
5896

5997
---
6098

@@ -90,6 +128,30 @@ java -jar cli/target/traffic-cli.jar samples/input_sample.json out/output.json
90128

91129
---
92130

131+
# Running Web App
132+
133+
To start the web application
134+
135+
### Run a backend
136+
```
137+
mvn -pl server spring-boot:run
138+
```
139+
140+
### Start a frontend
141+
```
142+
cd web/web
143+
npm install
144+
ng serve
145+
```
146+
147+
Then open
148+
```
149+
http://localhost:4200
150+
```
151+
152+
**Upload a simulation input JSON file and start the simulation.**
153+
154+
93155
# Input Format
94156

95157
The simulation accepts a JSON file containing a list of commands.
@@ -337,6 +399,28 @@ Vehicles in queues:
337399
}
338400
```
339401

402+
# Web Visualization
403+
404+
In addition to the CLI simulation, the project includes a **web visualization** built with Angular.
405+
406+
The web interface allows the user to:
407+
408+
- upload an `input.json` simulation file
409+
- start, stop and reset the simulation
410+
- visualize vehicles appearing on the intersection
411+
- highlight the active traffic phase
412+
- animate vehicles leaving the intersection
413+
- inspect the simulation trace step by step
414+
415+
The intersection is rendered using **SVG**, which allows precise positioning of vehicles and traffic lanes.
416+
417+
### Example UI
418+
419+
![intersection_web_app_ui.png](docs%2Fintersection_web_app_ui.png)
420+
421+
### Demo
422+
![SMT_michaelBak_UI_demo.gif](docs%2FSMT_michaelBak_UI_demo.gif)
423+
340424
# Project Assumptions
341425

342426
The simulation uses the following simplified traffic model:
@@ -418,6 +502,27 @@ Reasons:
418502
- simplifies debugging and testing
419503
- avoids random phase switching
420504

505+
# Continuous Integration
506+
507+
The project uses **GitHub Actions** to automatically run tests on every push and pull request.
508+
509+
The CI pipeline performs:
510+
511+
1. Backend build and tests (Maven)
512+
2. Frontend build and tests (Angular + Karma)
513+
514+
Example workflow:
515+
516+
```yaml
517+
Backend tests
518+
mvn -B -ntp test
519+
520+
Frontend tests
521+
npm ci
522+
npm test -- --watch=false --browsers=ChromeHeadless
523+
524+
```
525+
421526
# Tests
422527

423528
The project contains a set of unit and integration-style tests that verify the correctness of the simulation logic, input parsing and validation rules.
@@ -517,14 +622,3 @@ To execute the full test suite run:
517622
```
518623
mvn test
519624
```
520-
521-
# Possible Improvements
522-
523-
The current implementation focuses on correctness, determinism, and clarity. To make the system more realistic and feature-rich, the following extensions could be added:
524-
525-
- **Fairness & Starvation Prevention** – Introduce waiting-time based scoring to ensure low-demand directions are not ignored.
526-
- **Right Turn on Red** – Allow conditional right turns during incompatible phases if there is no conflicting traffic.
527-
- **Multi-Lane Roads** – Support separate lanes (left, straight, right) to allow multiple vehicles to pass simultaneously.
528-
- **Pedestrian Crossings** – Model pedestrian phases and request buttons that safely pause conflicting vehicle traffic.
529-
- **Traffic Statistics** – Collect data on average waiting times, queue lengths, and throughput to analyze algorithm efficiency.
530-
- **Visualization (Web UI)** – Build a graphical interface for real-time intersection monitoring and interactive command input.

docs/SMT_michaelBak_UI_demo.gif

2.2 MB
Loading

docs/intersection_web_app_ui.png

38.6 KB
Loading

server/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
<artifactId>server</artifactId>
1515

16+
1617
<dependencies>
1718

1819
<dependency>
@@ -28,4 +29,17 @@
2829

2930
</dependencies>
3031

32+
<build>
33+
<plugins>
34+
<plugin>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-maven-plugin</artifactId>
37+
<version>3.3.2</version>
38+
<configuration>
39+
<mainClass>pl.mbak.traffic.server.TrafficServerApplication</mainClass>
40+
</configuration>
41+
</plugin>
42+
</plugins>
43+
</build>
44+
3145
</project>

server/src/main/java/pl/mbak/traffic/server/TrafficserverApplication.java renamed to server/src/main/java/pl/mbak/traffic/server/TrafficServerApplication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import org.springframework.boot.autoconfigure.SpringBootApplication;
66

77
@SpringBootApplication
8-
public class TrafficserverApplication {
8+
public class TrafficServerApplication {
99
public static void main(String[] args) {
10-
SpringApplication.run(TrafficserverApplication.class, args);
10+
SpringApplication.run(TrafficServerApplication.class, args);
1111
}
1212
}

0 commit comments

Comments
 (0)