The server plays two roles in this applcation: - provides API for data persistence
- enables WebSocket connections
Data collected from the user is sent to a relevant Controller in the API which is utilizing Spring Data JPA for ORM and data persistence, so that no SQL needs to be written manually, all database communication is done by the framework itself including table creation, record persistence, retrieval and modification.
There are several tables - for each model respectively. Each model has a few basic fields to support the needs of the application. All models have autogenerated unique IDs and other fields that hold relevant data.
The UserController allows only one user with a given username to be created and updates the avatar each time the user enters data in the SignIn form.
Several other controllers communicate with relevant repositories and interfaces for other models, such as post, comment and like data.
When a user signs in its client subscribes to the main WebSocket topic (/feed-clients) on the server and whenever new data comes to the server from any of the clients the server distributes this data back to all clients triggering a re-render of the interface.
In this project I used JUnit5 and AssertJ to explore testing in Java. Apart from obvious assertions I learned the given/when/then flow and some mocking techniques to isolate particular pieces of logic to be tested as units.
Apart from above mentioned technologies I used Maven to manage dependencies, Lombok to eliminate boilerplate code on basic pojos and H2 in-memory database to run the project locally without the need to have Postgres database in development environment.