Skip to content

Anzyll/ecommerce-backend-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

54 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ E-commerce Backend API

An end-to-end e-commerce backend API built using Java and Spring Boot, designed with a strong focus on clean separation of concerns, security, and real-world backend design practices.
The system implements the complete core e-commerce workflow (excluding payments and logistics by design).


πŸš€ Features

πŸ” Authentication & Authorization

  • JWT-based authentication
  • Role-based access control (User / Admin)
  • Secure login and registration using Spring Security

πŸ‘€ User & Admin Management

  • User registration and authentication
  • Admin-controlled user management
  • Role-based endpoint protection

πŸ›οΈ Product Catalog

  • Product and category management
  • Filtering and search support
  • Admin-controlled product creation, update, and deletion

πŸ›’ Cart & Wishlist

  • User-specific cart management
  • Wishlist add/remove functionality

πŸ“¦ Order Management

  • Order creation from cart
  • Order lifecycle handling
  • User order history
  • Admin access to all orders and reports

πŸ“„ API Documentation

  • Interactive API documentation using Swagger (OpenAPI)

🧱 Tech Stack

Backend

  • Java
  • Spring Boot
  • Spring Security
  • Spring Data JPA (Hibernate)

Database

  • PostgreSQL
  • Flyway (Database migrations)

Security

  • JWT (JSON Web Tokens)
  • Role-based authorization

Documentation

  • Swagger / OpenAPI

πŸ—οΈ Architecture Overview

The application follows a feature-based modular architecture with layered separation of concerns.

Each feature (such as Auth, Cart, Order, Admin) is implemented as a vertical slice, containing its own controllers, orchestrators, services, and repositories.

Layer Responsibilities

Controller

  • Handles HTTP requests and responses
  • Performs request validation
  • Delegates execution to orchestrators
  • Contains no business logic

Orchestrator

  • Coordinates application workflows
  • Handles request-to-domain mapping (DTO β†’ Entity)
  • Composes multiple services to fulfill a use case
  • Manages flow control across domains
  • Keeps controllers thin and services reusable

Service

  • Encapsulates core business logic
  • Enforces domain rules and validations
  • Handles state transitions
  • Interacts with repositories
  • Remains orchestration-agnostic and reusable

Repository

  • Abstracts persistence logic
  • Uses Spring Data JPA for database access

Key Architectural Characteristics

  • Feature-based modularization (vertical slicing)
  • Layered architecture within each feature
    Controller β†’ Orchestrator β†’ Service β†’ Repository
  • Clear separation between orchestration and business logic
  • DTO pattern for request/response isolation
  • Repository pattern for persistence abstraction
  • JWT filter-based security using Spring Security
  • Configuration-as-code for security, migrations, and API documentation

πŸ—‚οΈ Project Structure (High Level)

src/main/java
 β”œβ”€β”€ auth
 β”œβ”€β”€ admin
 β”œβ”€β”€ cart
 β”‚   β”œβ”€β”€ controller
 β”‚   β”œβ”€β”€ orchestrator
 β”‚   β”œβ”€β”€ service
 β”‚   β”œβ”€β”€ repository
 β”‚   └── dto / entity
 β”œβ”€β”€ order
 β”œβ”€β”€ product
 β”œβ”€β”€ security
 └── config

πŸ§ͺ Testing

The project includes multiple levels of testing to ensure reliability and correctness.

Unit Tests

  • Implemented using JUnit 5 and Mockito
  • Tests service layer business logic
  • External dependencies are mocked

Controller Tests

  • Implemented using @WebMvcTest
  • Validates API endpoints, request validation, and responses

Repository Tests

  • Implemented using @DataJpaTest
  • Verifies database interactions and entity mappings

Integration Tests

  • Implemented using @SpringBootTest
  • Tests interactions between controller, service, and repository layers

End-to-End (E2E) Tests

Simulates complete workflows such as:

  • Cart β†’ Order checkout

🐳 Docker Support

The application can be run using Docker for consistent environments.

Build Docker Image

docker build -t ecommerce-backend .

Run Container

docker run -p 8080:8080 ecommerce-backend

Using Docker Compose (Recommended)

Runs both Spring Boot and PostgreSQL.

docker-compose up --build

βš™οΈ CI/CD Pipeline (GitHub Actions)

The project includes a CI/CD pipeline that automatically:

  • Builds the project using Maven
  • Runs tests
  • Builds a Docker image
  • Deploys the application to AWS EC2

Pipeline Flow

Code Push
   ↓
Build (Maven)
   ↓
Run Tests
   ↓
Docker Build
   ↓
Deploy to AWS EC2

☁️ Cloud Deployment (AWS)

The application is deployed using AWS infrastructure.

Infrastructure

EC2

  • Hosts the Spring Boot application

RDS (PostgreSQL)

  • Managed PostgreSQL database

Deployment Flow

Developer Push β†’ GitHub
        ↓
GitHub Actions
        ↓
Build Docker Image
        ↓
Deploy to EC2
        ↓
Application connects to RDS

βš™οΈ Getting Started

Prerequisites

  • Java 17+
  • Maven
  • PostgreSQL

Setup

  1. Clone the repository:
    git clone https://github.com/Anzyll/ecommerce-backend-api.git
  2. Configure PostgreSQL credentials in application.yml
  3. Flyway migrations run automatically on application startup
  4. Start the application:
    mvn spring-boot:run

πŸ“˜ API Documentation

Once the application is running, access Swagger UI at:

http://localhost:8080/swagger-ui.html

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors