Skip to content

kglusinski/cart-api

Repository files navigation

Cart API

A RESTful API for managing shopping carts, built with Symfony 7.2 and following Domain-Driven Design (DDD) principles.

Features

  • Create and manage shopping carts
  • Add/remove products to/from cart
  • Update product quantities in cart
  • View cart contents and total price
  • Product management (CRUD operations)
  • Input validation and error handling
  • API documentation with Swagger/OpenAPI

Requirements

  • PHP 8.2 or higher
  • Composer
  • MySQL 5.7+ or compatible database
  • Symfony CLI (recommended)

Installation

  1. Clone the repository:

    git clone [repository-url]
    cd cart-api
  2. Install dependencies:

    composer install
  3. Configure your environment:

    cp .env .env.local
    # Update the DATABASE_URL in .env.local with your database credentials
    # you could run docker compose up where the database is running
  4. Create and populate the database:

    php bin/console doctrine:database:create
    php bin/console doctrine:migrations:migrate
    php bin/console doctrine:fixtures:load
  5. Start the development server:

    symfony server:start

API Endpoints

Carts

  • POST /api/carts - Create a new cart
  • GET /api/carts/{cartId} - Get cart details
  • DELETE /api/carts/{cartId} - Clear cart
  • POST /api/carts/{cartId}/products - Add product to cart
  • PUT /api/carts/{cartId}/products/{productId} - Update product quantity in cart
  • DELETE /api/carts/{cartId}/products/{productId} - Remove product from cart

Products

  • GET /api/products - List all products
  • GET /api/products/{id} - Get product details
  • POST /api/products - Create a new product
  • PUT /api/products/{id} - Update a product
  • DELETE /api/products/{id} - Delete a product

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages