An opinionated Maven archetype to quickly bootstrap backend API on a sane basis. Pragmatic is in the early phase of development and is not production ready. Contributions are welcomed.
- Clone the project:
git clone git@github.com:salmanebah/pragmatic-archetype.git - Install locally:
mvn install - Generate a project:
cd directory/where/to/generateandmvn archetype:generate -DarchetypeCatalog=local - Follow the instructions to complete the generation.
- Only use frameworks and libraries when really needed:
Java SE > JSR > Spring framework > other libraries - Prefer programmatic Spring setup to their annotation-driven counterpart (exception in
Controller,RequestandResponseobjects) - Strive for rich domains and avoid anemic domains at all cost
- Avoid Mapping frameworks
- Restrict usage of mocking frameworks to the minimum. If possible use an in-memory version of the SUT collaborators.
- Keep these principles when writing tests
Pragmatic is based on:
- Spring Boot web framework
- Jooq for the Database access
- Flyway for database migration
- Test containers for integration tests
- ArchUnit for architecture level tests
- Docker and Docker Compose for local development
-
domainshould contain all theentities,value objects,aggregate rootsand domainevents -
usecaseshould contain all the system use cases. A use case can be defined as a complete interaction between a user and the system. -
repositoryshould contain all the persistent components that access the datasource. Repositories should deal withentitiesoraggregate roots. -
serviceshould contain domain and application services. -
taskshould contain asynchronous and scheduled jobs. A task should beRunnableorCallableand must be configured in a Spring Configuration class (i.e without using the@Scheduledannotation). -
restshould contain the API controllers, requests, responses and mappers. -
configurationshould contain all the spring configuration related classes. Spring Beans must be created explicitly (i.e without@Repository,@Service, ... stereotypes)
- i18n-ready API error messages and default messages for common errors
- Swagger documentation under
/api-docand/swaggerfor all controllers - A docker and docker compose environment for local development
- Monitoring with Actuator available at
/actuator, Prometheus on port9090and Grafana on port3000(default admin password is !changeMe!) - A Github pipeline to run unit and integration tests upon pull request and merge on the
masterbranch
mvn generate-sources -Pjooqto generate jooq classes from migration filesmvn testto only execute unit testsmvn verify -Pitto only execute integration testsmvn verifyto execute all the testsdocker-compose upto run the application and all the dependencies
