A REST API for managing recipes and shopping carts, built with Micronaut and Kotlin.
GET /recipes
- List all available recipes with ingredients
GET /carts/{id}
- Get cart by ID with items and recipesPOST /carts/{id}/add_recipe
- Add a recipe to cart (I would change it to/carts/{id}/recipes
for consistency with the DELETE endpoint and because it's more RESTish)DELETE /carts/{id}/recipes/{recipeId}
- Remove a recipe from cart
- Micronaut 4.3.5 - Framework
- Kotlin - Programming language
- H2 - Database
- Flyway - Database migrations
- Micronaut Data JDBC - Data access layer
- JUnit 5 - Testing
- MockK - Mocking framework
The application uses the following tables:
products
- Product information (name, price)recipes
- Recipe information (name, description, servings, prep time)recipe_ingredients
- Recipe-to-product relationshipscarts
- Shopping cart informationcart_items
- Individual product items in cartscart_recipes
- Recipes added to carts
./gradlew run
The API will be available at http://localhost:8081
./gradlew test
./gradlew build
The application comes with sample data including:
Products:
- Tomatoes, Mozzarella, Basil, Olive Oil
- Pasta, Garlic, Chicken Breast, Onion, Bell Pepper, Rice
Recipes:
- Margherita Pizza (Tomatoes, Mozzarella, Basil, Olive Oil)
- Chicken Stir Fry (Chicken Breast, Onion, Bell Pepper, Rice)
- Pasta Aglio e Olio (Pasta, Garlic, Olive Oil)
Sample Carts:
- 3 empty carts (IDs: 1, 2, 3)
curl http://localhost:8081/recipes
curl http://localhost:8081/carts/1
curl -X POST http://localhost:8081/carts/1/add_recipe \
-H "Content-Type: application/json" \
-d '{"recipe_id": 1, "quantity": 1}'
curl -X DELETE http://localhost:8081/carts/1/recipes/1
src/
├── main/
│ ├── kotlin/me/andreaiacono/
│ │ ├── controller/ # REST controllers
│ │ ├── dto/ # Data transfer objects
│ │ ├── model/ # Domain models
│ │ ├── repository/ # Data repositories
│ │ ├── service/ # Business logic
│ │ └── Application.kt # Main application class
│ └── resources/
│ ├── application.yml # Application configuration
│ └── db/migration/ # Database migrations
└── test/
├── kotlin/me/andreaiacono/
│ ├── controller/ # Controller tests
│ └── service/ # Service tests
└── resources/
└── application-test.yml # Test configuration
I used Claude Code for creating the project and then I re-arranged quite some things here and there for improving it.