Pero Grubač

eMobilityHub

Electric vehicle rental platform: four apps on one database.

ArchitectureAngular → Nginx → Spring Boot API + JSP apps → MySQL

/rsscookie + CSRF tokenBearer JWTJPA · FlywayJDBCEmployeesadmin · operator · managerManagerspromotions, announcementsRSS readerspublic feedsClientsrent, ride, payEmployee appAngular · Nginx :80, proxies /apiPromotions appJSP · Tomcat :8082Client appJSP · Tomcat :8081Spring Boot API · :8080JWT filter · CSRF · role rules → controllers → services → JPAuploadsvehicle imagesMySQL 8schema by Flyway
Three front ends and the RSS feeds on one Spring Boot API, and a client web shop that reads MySQL directly over JDBC, as the assignment required. The API owns the schema: Flyway migrates it on start.
eMobilityHub: the operator's vehicle map, with the fleet of cars, bicycles and scooters on a city map marked as available, rented or broken, and the car a client has just rented selected

What it does

I built eMobilityHub as a rental platform for electric cars, bicycles and scooters, for a fictional rental company. It is four applications on one MySQL database, one for each kind of user:

  • Employees use an Angular back office. Administrators manage the fleet, manufacturers, clients and employees and import vehicles from CSV. Operators follow the rentals and see every vehicle on a map, coloured by its status. Managers can do both, and they also set the rental prices and read the revenue and fault statistics.
  • Clients use a mobile-first web shop built with JSP. They register, pick a vehicle, set the start location, show an ID document and a driver’s licence for a car, pay by card, ride with a live clock and running price, and get a PDF invoice when they finish. They can also report a broken vehicle and see all their rentals.
  • Managers publish promotions and announcements in a separate JSP portal, and both are also available as RSS feeds.
  • A Spring Boot API sits behind the back office and the promotions portal.

Architecture

The Angular back office is served by Nginx, which also forwards its API calls to Spring Boot, so the browser talks to one origin and the session cookie stays first-party. The promotions portal calls the API from its own server, with the manager’s token in a Bearer header. RSS readers get the feeds straight from the API.

The client web shop is a classic Model 2 application (servlets and JSP) on its own Tomcat, and it reads and writes MySQL directly over JDBC: the assignment did not allow it to use the REST API.

The API owns the database schema. Flyway migrates it when the API starts and Hibernate only validates it; in Docker, the two JSP apps wait until the API reports healthy, because the schema has to exist first. Inside the API, every request passes the JWT filter, CSRF protection and the role rules before it reaches the controllers, services and JPA repositories. Vehicle images are kept in their own volume.

Decisions and why

  • One API, several front ends. I put the back office and the promotions portal on the same REST API, so the business rules and role checks live in one place.
  • A cookie for browsers, a Bearer header for servers. Browsers get the JWT in an httpOnly, SameSite=Strict cookie that scripts cannot read, and a CSRF token is required exactly when that cookie authenticates a write. The promotions portal is a server-side client, so it sends a Bearer header and needs no CSRF token.
  • The same origin everywhere. Nginx in Docker, and a proxy during development, put the single-page app and the API on one origin, so the cookie stays first-party and there is no CORS to get wrong.
  • The API owns the schema. Docker, the integration tests and CI all build the database from the same Flyway migrations.
  • Joined inheritance for vehicles. Common columns live in one table and each vehicle type has its own, so the statistics can group revenue by vehicle type in a JPQL query.
  • Shared CRUD base classes. I wrote paging, CRUD, renting, breaking and fixing, and image handling once; each vehicle type only adds its own fields.
  • The CSV import goes row by row. A bad row is reported with its row number and the reason, and every valid row is still saved.

Security

  • Every endpoint has an explicit role rule on the server, and anything not listed is denied. The Angular menus only mirror those rules.
  • Passwords are hashed with BCrypt.
  • A broken token counts as anonymous, not as an error: an expired or forged token never causes a server error, the rules answer 401 or 403, and a 401 sends the back office to the sign-in page.

Testing and deployment

The API has 104 tests, the two JSP apps 73 and the Angular app 64. The API tests run the real security configuration through MockMvc (401 versus 403, broken tokens, cookie flags, when CSRF is required) and the whole API on MySQL 8 in Testcontainers, with the schema from Flyway and a 27-case role matrix. The client shop’s data access is tested on a MySQL database built from the API’s migrations: one active ride per client, rented or broken vehicles refused, and invoices only for their owner.

CI runs only what changed: it works out which apps a commit touched and runs the API, JSP and Angular jobs for those. Then it builds every image, starts the stack with health checks, checks that every app answers, and signs in through Nginx to verify the cookie session and the CSRF protection. Maven, npm, the Angular build and the Docker layers are cached, and a newer push cancels the run before it. On main, the four images are published to the GitHub Container Registry.

HomepageAboutsectionSystemssectionIndex of projectssectionBrowser appspageContactsectionIncident Alertsystem · case studyeMobilityHubsystem · case studyChat Roomsystem · case studyOnline Library Systemsystem · case studyRepoHealthlive app · case studyOpen RepoHealth app (opens in a new tab)live appGitHub Discord Bottool · case studyBookstore APIweb project · case studyFitForgemobile app · case studyAssetManagermobile app · case studyStore Managementdesktop app · case studyETF Oglasimobile app · case studyDevKitlive app · case studyOpen DevKit app (opens in a new tab)live appDev Timelinelive app · case studyOpen Dev Timeline app (opens in a new tab)live appGitHub Dashboardlive app · case studyOpen GitHub Dashboard app (opens in a new tab)live appStore Chain Managementdesktop app · case studySecure Repositorytool · case studyMinimal Blogweb project · case studyCatan Map Generatorlive app · case studyOpen Catan Map Generator app (opens in a new tab)live appMonte Carlo π · Pythonlive app · case studyOpen Monte Carlo π · Python app (opens in a new tab)live appBrick Breakerlive app · case studyOpen Brick Breaker app (opens in a new tab)live appArcane Keeplive app · case studyOpen Arcane Keep app (opens in a new tab)live appe-Mobility Rentaldesktop app · case studyCountdownlive app · case studyOpen Countdown app (opens in a new tab)live appANOVAdesktop app · case studyEcho Playerdesktop app · case studyMonte Carlo πdesktop app · case studyexcuse.exelive app · case studyOpen excuse.exe app (opens in a new tab)live appYamb Tablelive app · case studyOpen Yamb Table app (opens in a new tab)live appSedmicalive app · case studyOpen Sedmica app (opens in a new tab)live appLora Score Tablelive app · case studyOpen Lora Score Table app (opens in a new tab)live appSnake (Blavor)desktop app · case study
Copy emailpero.grubac00@gmail.com