Monet is a project which came to life with the educational purpose, and was inspired by the excellent Practical FP in Scala book by Gabriel Volpe. Monet's goal is to implement an API for a backend of an online paintings retail platform, in Scala 3, with the functional programming paradigm using the Typelevel stack.
Latest update: Monet was initially completed in early 2023, and it has been updated and openly published in the summer of 2024.
Monet specification includes:
- Functional requirements document, which specifies business requirements
- Design document, which specifies domain model and API routes
Monet uses the following libraries:
- cats, for functional programming abstractions
- cats-effect, for concurrency and IO monad
- cats-retry, for retrying failing effects
- circe, for encoding/decoding JSON
- fs2, for purely functional streams
- http4s, for purely functional HTTP servers/clients
- http4s-jwt-auth, for JWT authentication
- kittens, for cats' typeclass deriving
- log4cats, for purely functional logging
- monix-newtypes, for defining newtypes
- monocle, for access and transformation of immutable data
- pureconfig, for loading and handling configurations
- redis4cats, for a Redis client compatible with cats-effect/fs2
- skunk, for purely functional PostgreSQL client
- weaver, for testing compatible with cats-effect/fs2
If you are using Docker:
- Create and publish Monet Docker image:
sbt docker:publishLocal- Run Monet with accompanying services (PostgreSQL and Redis):
sudo docker network create monet-network
docker-compose -f app/docker-compose.yml up -dIf you do not want to use Docker:
- Ensure both PostgreSQL and Redis instances are running locally
- Ensure
$MONET_ENVenvironment variable is set to eitherprodortest - Make sure the configuration file is specified correctly (note that in the linked example
PostgreSQL and Redis hosts are Docker-specific so you will need to modify them, for example to
localhost). - Inside
sbt, runreStart. To stop Monet, runreStop.
To run unit tests execute:
sbt testTo run integration tests, execute:
docker-compose -f tests/docker-compose.yml up -d
sbt it:test
docker-compose -f tests/docker-compose.yml down- Add a new admin account type to enable different management tasks (e.g., adding painting techniques/categories)
- Optimize painting update http route by writing only data that is being updated
- Use BouncyCastle instead of javax.crypto, and use GCM instead of CBC mode
- Add caching layer
- Introduce Iron for (both runtime and compile time) refined types (also for newtypes)
If you have suggestions for improvements, or think that I've done something wrong, feel free to open an issue.
Pull requests are also more than welcome.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.