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).
- JWT-based authentication
- Role-based access control (User / Admin)
- Secure login and registration using Spring Security
- User registration and authentication
- Admin-controlled user management
- Role-based endpoint protection
- Product and category management
- Filtering and search support
- Admin-controlled product creation, update, and deletion
- User-specific cart management
- Wishlist add/remove functionality
- Order creation from cart
- Order lifecycle handling
- User order history
- Admin access to all orders and reports
- Interactive API documentation using Swagger (OpenAPI)
- Java
- Spring Boot
- Spring Security
- Spring Data JPA (Hibernate)
- PostgreSQL
- Flyway (Database migrations)
- JWT (JSON Web Tokens)
- Role-based authorization
- Swagger / OpenAPI
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.
- Handles HTTP requests and responses
- Performs request validation
- Delegates execution to orchestrators
- Contains no business logic
- 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
- Encapsulates core business logic
- Enforces domain rules and validations
- Handles state transitions
- Interacts with repositories
- Remains orchestration-agnostic and reusable
- Abstracts persistence logic
- Uses Spring Data JPA for database access
- 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
src/main/java
βββ auth
βββ admin
βββ cart
β βββ controller
β βββ orchestrator
β βββ service
β βββ repository
β βββ dto / entity
βββ order
βββ product
βββ security
βββ config
The project includes multiple levels of testing to ensure reliability and correctness.
- Implemented using JUnit 5 and Mockito
- Tests service layer business logic
- External dependencies are mocked
- Implemented using @WebMvcTest
- Validates API endpoints, request validation, and responses
- Implemented using @DataJpaTest
- Verifies database interactions and entity mappings
- Implemented using @SpringBootTest
- Tests interactions between controller, service, and repository layers
Simulates complete workflows such as:
- Cart β Order checkout
The application can be run using Docker for consistent environments.
docker build -t ecommerce-backend .docker run -p 8080:8080 ecommerce-backendRuns both Spring Boot and PostgreSQL.
docker-compose up --buildThe 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
Code Push
β
Build (Maven)
β
Run Tests
β
Docker Build
β
Deploy to AWS EC2
The application is deployed using AWS infrastructure.
EC2
- Hosts the Spring Boot application
RDS (PostgreSQL)
- Managed PostgreSQL database
Developer Push β GitHub
β
GitHub Actions
β
Build Docker Image
β
Deploy to EC2
β
Application connects to RDS
- Java 17+
- Maven
- PostgreSQL
- Clone the repository:
git clone https://github.com/Anzyll/ecommerce-backend-api.git
- Configure PostgreSQL credentials in
application.yml - Flyway migrations run automatically on application startup
- Start the application:
mvn spring-boot:run
Once the application is running, access Swagger UI at:
http://localhost:8080/swagger-ui.html