Skip to content

Somtrip/buyBuddyBackend

Repository files navigation

BuyBuddy Backend 🛒

A modern, scalable microservices-based e-commerce backend built with Spring Boot and Spring Cloud. BuyBuddy provides a robust foundation for customer, product, and order management with service discovery capabilities.

Features

  • Microservices Architecture: Three independent services (Customer, Product, Order)
  • Service Discovery: Integrated Eureka server for service registration and discovery
  • RESTful APIs: Clean, well-structured endpoints for all operations
  • CORS Enabled: Pre-configured for frontend integration
  • MySQL Integration: Persistent data storage with JPA
  • Admin Dashboard: Built-in management UI

Tech Stack

  • Java 17
  • Spring Boot 3.x
  • Spring Cloud (Eureka, Feign Clients)
  • MySQL Database
  • Gradle Build System

Quick Start

Prerequisites

  • Java 17 or higher
  • MySQL Server
  • Gradle (or use included wrapper)

Installation

  1. Clone and setup the database:
mysql -u root -p -e "CREATE DATABASE buybuddy_microservices_mysql_db"
  1. Update database credentials in each service's application.properties:
spring.datasource.username=your_username
spring.datasource.password=your_password
  1. Start the services (in order):
# Start Eureka Server (port 8761)
cd eureka-server && ./gradlew bootRun

# Start Customer Service (port 8081)
cd ../buy-buddy-customer-service && ./gradlew bootRun

# Start Product Service (port 8082)  
cd ../buy-buddy-product-service && ./gradlew bootRun

# Start Order Service (port 8083)
cd ../buy-buddy-order-service && ./gradlew bootRun

API Endpoints

Customer Service (:8081)

  • GET /api/customers - List all customers
  • POST /api/customers - Create new customer
  • GET /api/customers/{id} - Get customer by ID
  • PUT /api/customers/{id} - Update customer
  • DELETE /api/customers/{id} - Delete customer

Product Service (:8082)

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

Order Service (:8083)

  • GET /api/orders - List all orders
  • POST /api/orders - Create new order
  • GET /api/orders/{id} - Get order by ID
  • DELETE /api/orders/{id} - Delete order

Testing Endpoints

Use Postman or curl to test:

Customer Service

  • Create customer:

    POST http://localhost:8081/api/customers
    Body: {"name": "Crio Beaver", "email": "beaver@criodo.com"}
  • Get customers:

    GET http://localhost:8081/api/customers

Product Service

  • Create product:

    POST http://localhost:8082/api/products
    Body: {"name": "iPad Air", "price": 60000}
  • Get products:

    GET http://localhost:8082/api/products

Order Service

  • Create order:

    POST http://localhost:8083/api/orders
    Body: {"customerId": 1, "productIds": [1, 2]}
  • Get order:

    GET http://localhost:8083/api/orders/1

Important Notes

  1. Ensure MySQL is running before starting services
  2. Verify all services are registered in Eureka dashboard: http://localhost:8761
  3. Database configurations should be properly set in each service's application.properties

Troubleshooting

  • If services fail to start, check database connection settings
  • Verify all dependencies are properly imported in build.gradle files
  • Ensure correct port configurations for each service

Admin Dashboard

Access the built-in admin interface at http://localhost:8081 after starting the customer service. The dashboard provides:

  • Customer management
  • Product catalog management
  • Order processing
  • Real-time statistics

Development

Each service is a standalone Spring Boot application. Use the included Gradle wrapper to build and run:

./gradlew build
./gradlew bootRun

Configuration

Key configuration files:

  • application.properties - Database and server settings
  • WebConfig.java - CORS and web configuration
  • Feign clients for inter-service communication

License

This project is part of the BuyBuddy e-commerce platform.

About

Scalable Spring Boot + Spring Cloud microservices backend for e-commerce

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors