A simple app with a Java backend and Angular frontend. This is the sixth project of my course as a full-stack Java / Angular developer with OpenClassrooms. The goal here is to write a full app with separated front and backend.
- Java 23
- Access to a MySQL (or MariaDB) server and a database
- Maven
- Git
- Postman for testing purposes
- Mockoon to run a mock Restful API as backend if needed
- Clone this repository on your local machine or server and go to directory
git clone https://github.com/wilzwert/MDD.git
cd savasana- Configuration
This application uses a .env file to configure most of its parameters. Please copy the provided .env.example file to .env
Linux / unix :
cp .env.example .envWindows
copy .env.example .envThen setup variables according to your environment ; see .env.example for more information. Please note that there is a slight difference whether you're using MySQL or MariaDB, although default values should work for both.
OPTIONAL - Import the schema and data provided in resources/sql into your database.
Starting the backend should create database tables, however you can create the database schema by importing the file provided in resources/sql/db_structure.sql
You can either use a GUI like PhpMyAdmin or load the file from command line :
mysql -u user -p database_name < ressources/db_structure.sqlYou can also populate the database with test data by importing the file provided in resources/sql/reset_data.sql Please note that this script also clears all previous data.
mysql -u user -p database_name < ressources/db_structure.sql- Install backend dependencies
cd back
mvn clean installOr directly in your favorite IDE
- Install frontend dependencies
cd front
npm installWindows :
cd back
mvnw spring-boot:runLinux / unix :
cd back
mvn spring-boot:runThis will make the API available on localhost:8080.
- run frontend
cd front
npm run startor
cd front
ng serveThis will make the frontend available on localhost:4200.
Should you wish to run the frontend on a "mock" API, you can import the file provided in resources/mockoon/mdd.json and edit proxy configuration in front/proxy.conf.json to reflect your Mockoon API host and port.
- With provided Postman collection : see resources/postman/MDDApi.postman_collection.json
Import the collection in Postman : https://learning.postman.com/docs/getting-started/importing-and-exporting-data/#importing-data-into-postman
Then run the collection.
Once the backend application is started, you should be able to access the API Documentation (please adjust host and port to your environment).
If you set a custom SWAGGER_PATH in .env, for example
SWAGGER_PATH=/api-doc
You can also access Swagger UI on http://localhost:8080/api-doc
Please note that even if you did set a custom Swagger path, you will be redirected to /swagger-ui/index.html
Unitary and integration tests are located in back/src/test/java/com.openclassrooms.mdd. Unitary tests classes names are suffixed by 'Test', integration tests classes names are suffixed by 'IT'.
cd back
Unitary tests are run with Maven Surefire Plugin.
mvn clean test
Jacoco report with code coverage is located in target/site/jacoco-ut/index.html
Integration tests are run with Maven Failsafe Plugin.
mvn clean verify
Jacoco report with code coverage is located in target/site/jacoco-merged/index.html
Unitary tests filenames are suffixed with .spec.ts.
Integration tests filenames are suffixed with .integration.spec.ts.
Launching tests:
npm run test
for following change:
npm run test:watch
Launch unitary and integration tests with coverage report generation
npm run test:coverage
Report is available here:
front/coverage/jest/lcov-report/index.html
End-to-end tests files are located in front/cypress/e2e.
Launching e2e tests manually with Cypress UI :
npm run e2e
Launching all e2e tests automatically in CLI (headless) with report generation :
"npm run e2e:ci"
Report is available here:
front/coverage/e2e/lcov-report/index.html
- JWT Token authentication
- Request data validation through DTO
- Entities relationships
- Cascade handling
- Global exception handler generating Http responses with appropriate Http status codes
- Logging levels can be configured in src/main/resources/application.properties. Defaults:
logging.level.root=warn
logging.level.org.springframework.security=warn
logging.level.com.openclassrooms.mdd=error
logging.level.com.openclassrooms.mdd.service=error
logging.level.com.openclassrooms.mdd.controller=error
logging.level.org.hibernate.SQL = warn
Level 'info' for services and controllers can get very verbose under certain circumstances :)
Javadoc may be improved by better commenting backend code As of now, you can generate javadoc by running
cd back mvn javadoc:javadoc
Javadoc should be available in target/site/apidocs/index.html
Frontend code could and should be better documented as well.
As of now, local cache of data (user subscriptions, current user...) are handled by observables exposed in or subscribed by services which in turn observe the user logged status to clear themselves when needed.
This may be better handled by the use of Signals and/or a central store to manage data.
Implementing a pagination, especially in the "Post" page, could become mandatory to improve UX as the the article number grows.