Messenger is a simple messaging application where registered users can post messages. The project acts as an example project for a single-page application implemented with Spring Boot and React.
The project architecture consists of the backend application and the frontend application. The backend application is a RESTful web service implemented with Spring Boot. It provides a REST API endpoints for the frontend application. The backend application's authentication is implemented with a stateless JWT token authentication. The backend application uses H2 Database Engine as a development environment database and PostgreSQL as a production environment database.
The frontend application is implemented with React. The user-interface is implemented with Material UI. The Vite build tool is used to develop and build the frontend application.
The backend application requires Java 17 as a minimum version.
You need to perform the following steps to setup the backend application:
-
Add a
application-local.properties
file to thesrc/main/resources
folder (same folder that has theapplication.properties
file) with the following content:auth.jwt-secret=<jwt-secret>
Replace the
<jwt-secret>
with a string that has at least 48 characters.
Then, you can start the backend application by performing the following steps:
- Start the server by running the
./mvnw spring-boot:run
command - Once the server has started, the application is accessible at http://localhost:8080
You can run the backend tests by running the ./mvnw test
command.
Docker can be used to deploy the backend application or run it locally. In the production environment, the Docker container requires the environment variables defined in the application-production.properties file.
The backend application can be started with Docker by performing the following steps:
- Build the image by running the
docker build . -t messenger-backend
command - Create and start the container by running the
docker run -p 8080:8080 messenger-backend
command - Once the server has started, the application is accessible at http://localhost:8080
By setting the SPRING_PROFILES_ACTIVE
environment variable value as production
, the application will use the production environment properties.
The frontend application requires Node.js 18 as a minimum version.
You can start the frontend application by performing the following steps in the frontend
folder:
- Install the dependencies by running the
npm install
command - Start the Vite development server by running the
npm run dev
command - Once the development server has started, the application is accessible at http://localhost:5173
- Swagger documentation (accessible when the backend server is running)