This is the Scala project for the Hivemind Technologies blog article about ZIO Layers (ZLayers). You can find the article in this link.
The application is structured in 4 different layers:
- Application
- Service
- Repository
- Database
%%{init: {"flowchart": {"htmlLabels": false}} }%%
flowchart TB
subgraph appLayer["Application Layer"]
direction LR
app["Application"]
appConfig["App Config"]
appLogger["App Logger"]
end
subgraph serviceLayer["Service Layer"]
propService["Property Service"]
userService["User Service"]
end
subgraph repoLayer["Repository Layer"]
userRepo["User Repository"]
propRepo["Property Repository"]
end
subgraph dbLayer["Database Layer"]
database["Database"]
db[(Database)]
dbConfig["Database Config"]
dbLogger["DB Logger"]
end
app -. " findUser() " .-> userService -. " getUserById() " .-> userRepo -. " getObjectById() " .-> database -. " SQL query " .-> db
app -. " findProperty() " .-> propService -. " getPropertyById() " .-> propRepo -. " getObjectById() " .-> database
app -. " findPropertiesOfUser() " .-> propService -. " getPropertiesByOwnerId() " .-> propRepo -. " getAllRecords() " .-> database
database -. " uses " .-> dbLogger
database -. " uses " .-> dbConfig
This will clean the compilation files (*.class) from the project:
sbt clean
The following command with format all the Scala files (*.scala) according to the scala format file provided in the project (.scalafmt.conf)
sbt fmt
The following command will compile the main project files:
sbt compile
This will execute all the tests in the project:
sbt test
The sbt check
command will execute the following steps:
- Clean all compilation files (*.class)
- Format all project files
- Compile all project files (including test classes)
- Execute all the tests
sbt check