Skip to content

cnogueira/trolley

Repository files navigation

Build Status Badge Build Status Badge

Trolley

Yet Another Cart Manager application

Tests

Run tests with

./gradlew clean check

Note that you must have at least java 8 jdk installed in order to run the tests.

Run in docker

docker-compose up --build

Will deploy the application on port 8080 of localhost.

Documentation

Examples assume the application is reachable on http://localhost:8080

Create Cart

request
POST /api/v1/carts HTTP/1.1
Content-Length: 17
Content-Type: application/json;charset=UTF-8
Host: localhost:8080

{"name":"cart 1"}
response
HTTP/1.1 201 Created
Content-Length: 72
Content-Type: application/json;charset=UTF-8

{"id":"f67ff566-4921-44e2-a9fe-d95f04a0a936","name":"cart 1","items":[]}

Get Cart

request
GET /api/v1/carts/695f20a8-baa5-4722-965b-9a5085fcb120 HTTP/1.1
Host: localhost:8080
response
HTTP/1.1 200 OK
Content-Length: 75
Content-Type: application/json;charset=UTF-8

{"id":"695f20a8-baa5-4722-965b-9a5085fcb120","name":"some name","items":[]}

Add Item

request
POST /api/v1/carts/5ac1d550-6bae-4fd1-a391-8c4e9826c5e6/items HTTP/1.1
Content-Length: 17
Content-Type: application/json;charset=UTF-8
Host: localhost:8080

{"name":"item 2"}
response
HTTP/1.1 201 Created
Content-Length: 61
Content-Type: application/json;charset=UTF-8

{"id":"e966e20e-9fe4-43bf-9eba-cdd7156d0196","name":"item 2"}

Improvements

  • Make RedisCartRepository a cache, and use a proper persistence based repository (e.g. a cart repository based on PostgreSQL). As that should be transparent to RedisService, I’d make RedisCartRepository use a decorator pattern to hide the fact that it acts as a cache from its consumers.

  • Provide DELETE functionality, specifically for items added in a cart.

  • Clean-up configuration: Right now RedisCartRepository is injected if a REDIS_URL environment variable is present. That clearly should be moved to configuration files (i.e. application.properties file).

About

Yet Another Cart Manager

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published