Files
yohoho/README.md
Benjamin Sigonneau b78b8cca41 Refactor: split into multiple files
Given the size of the assignment, having everything in the same file was
OK. However, splitting into different files is a good option for better
maintainance once this API grows, and now is a good time to do it before
it gets more complicated.
2026-02-01 03:06:00 +01:00

51 lines
1.8 KiB
Markdown

# Yohoho - A take-home assignment for HolidayPirates
This is my take on the take-home assignment I was given for the Backend Engineer
position at HolidayPirates.
The goal is to implement a very small REST API in Clojure. That API provides two
endpoints :
* `POST /items`: creates an item
* `GET /items`: returns the list of items
## Usage
This project uses Leiningen. Assuming you already have Leiningen installed,
running the API should be as easy as cloning the repo and issuing `lein run`. By
default, the server listens on port 3000.
## Structure
The source code lies in `/src/yohoho` and is structured as follows:
* `app.clj`: ring app and main entrypoint
* `config.clj`: configuration (database and HTTP server)
* `db.clj`: functions that directly interact with the database
* `handlers.clj`: route handlers
* `helpers.clj`: the infamous file that holds function that are useful but
couldn't fit anywhere else
* `routes.clj`: API routes
* `schemas.cls`: Malli schemas used for validation
## Library choices
* `reitit`: for handling routes
* `jetty`: web server
* `muuntaja`: JSON handling
* `next.jdbc`: database interface (SQLite)
* `malli`: validation
## Documentation links
The following links proved more than useful when working on this assignment:
* <https://practical.li/clojure-web-services/building-api/>
* <https://github.com/metosin/reitit/blob/master/doc/ring/content_negotiation.md>
* <https://ostash.dev/posts/2021-08-22-data-validation-in-clojure/>
* <https://clojurecivitas.github.io/malli/elements_of_malli.html>
* <https://github.com/metosin/reitit/blob/master/doc/coercion/malli_coercion.md>
* <https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.3.1086/doc/getting-started>
* <https://cljdoc.org/d/metosin/reitit/0.10.0/doc/ring/swagger-support>
* <https://www.baeldung.com/clojure-ring>