Skip to content

filiprd/monet

Repository files navigation

Monet CI License Cats friendly

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.

Specs

Monet specification includes:

Tech Stack

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

Running Monet

If you are using Docker:

  1. Create and publish Monet Docker image:
sbt docker:publishLocal
  1. Run Monet with accompanying services (PostgreSQL and Redis):
sudo docker network create monet-network
docker-compose -f app/docker-compose.yml up -d

If you do not want to use Docker:

  1. Ensure both PostgreSQL and Redis instances are running locally
  2. Ensure $MONET_ENV environment variable is set to either prod or test
  3. 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).
  4. Inside sbt, run reStart. To stop Monet, run reStop.

Tests

To run unit tests execute:

sbt test

To run integration tests, execute:

docker-compose -f tests/docker-compose.yml up -d
sbt it:test
docker-compose -f tests/docker-compose.yml down

Future improvements

  • 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)

Contributions

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.

License

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.

About

Online paintings retailer platform implemented in functional Scala 3

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages