Online Shop Application created for educational purpose to test different technologies, architectural and design styles. VShop "V" stands for Vertically sliced design. For the sake of simplicity the entire application is implemented as a modular monolith. Business functions are layered in separate packages (vertically sliced modules / per function or per domain) and can be extracted to separate microservices when needed later on.
- Infinispan 14 (connected to Oracle XE) Infinispan is not used in the current version of the project
- Oracle 21c XE
- Two users are created on first setup (vshop and vshopcache) -
see SQL init scripts
- vshopcache user is dedicated to the Infinispan JDBC persistent storage
- vshop user is the application user
- Two users are created on first setup (vshop and vshopcache) -
see SQL init scripts
- MongoDB 6 (with vshop user)
The whole application for the development simplicity is stored in the one project (and the deployment package). However, the application is vertically sliced into the separate functional modules (domains). Modules are expressed as packages.
As the project is under development and for the learning purposes the modules will be added gradually. The following modules are already implemented:
- products - the module works with 4 spring profiles:
JPA
,SODA
,JSON
,MONGO
. Each profile uses different persistence layer.
- Docker
- JDK 17 (ensure that
JAVA_HOME
points to JDK 17 dir - required by the Gradle Wrapper)
Running Oracle profiles (JPA
, SODA
, JSON
):
gradlew initDocker
docker-compose -f vshop-docker\docker-compose.yaml up -d oracle
gradlew initDB
gradlew build
gradlew bootRun --args='--spring.profiles.active=JSON'
Running MongoDB profile (MONGO
):
gradlew initDocker
docker-compose -f vshop-docker\docker-compose.yaml up -d mongo
gradlew build
gradlew bootRun --args='--spring.profiles.active=MONGO'
Before you run the docker compose command please initialize the project:
gradlew initDocker
It will download the Oracle JDBC jar for you (from the Maven Central) placing it to
the vshop-docker/infinispan/server/lib
. This folder is dedicated to the Infinispan 3rd party libraries. Read more
about the Infinispan server
folder https://infinispan.org/docs/stable/titles/server/server.html#server_root_directory
To build the project just run the following command:
gradlew build
Go to the vshop-docker
and run the following command
docker-compose up -d
It will start 3 containers:
- Oracle 21c XE
- Infinispan 14 (connected to the Oracle DB) Infinispan is not used in the current version of the project
- MongoDB 6
If you want to start only the Oracle DB or MongoDB you can run the following command:
docker-compose up -d oracle
docker-compose up -d mongo
Before you run the application you need to initialize the database. The following task will create all the necessary tables for all Oracle spring profiles (JPA, SODA, JSON).
gradlew initDB
The application is configured to run with the following profiles: JPA
, SODA
, JSON
, MONGO
.
JPA
profile is used to run the application with the JPA (Hibernate) persistence layer.
gradlew bootRun --args='--spring.profiles.active=JPA'
SODA
profile is used to run the application with the Oracle SODA persistence layer.
gradlew bootRun --args='--spring.profiles.active=SODA'
JSON
profile is used to run the application with the Oracle JSON persistence layer.
gradlew bootRun --args='--spring.profiles.active=JSON'
MONGO
profile is used to run the application with the MongoDB persistence layer.
gradlew bootRun --args='--spring.profiles.active=MONGO'
At the time the only way to access application is to use the Swagger UI. The Swagger UI is available under the following URL: http://localhost:8080/swagger-ui/index.html
The following request will generate 1000 products and store them in the database:
POST http://localhost:8080/products/generate
Accept: application/json
Content-Type: application/json
{
"numberOfProducts": 1000
}
Then you can search the products using the following request:
GET http://localhost:8080/products?textContains=whaleboat