A modular monolith e-commerce application built with Java and Spring Boot, focused on backend development, domain modeling, data integrity, automated testing, and maintainable software design.
The project simulates core e-commerce workflows, including user management, product catalog, inventory, shopping carts, checkout, and order management. It is also a practical environment for exploring engineering trade-offs in a realistic application.
Project status: Under active development. Features are identified as implemented, in progress, or planned to distinguish the current state from the intended scope.
SpringEcommerce is a REST API for an online store, designed as a modular monolith. Its codebase is organized around business capabilities, with modules responsible for specific parts of the application.
The project emphasizes:
- Separation of responsibilities between application, domain, infrastructure, and presentation concerns where applicable.
- Business rules and data integrity in critical workflows.
- Transaction management across related operations.
- Automated tests at different levels.
- Dynamic product filtering and paginated API responses.
- API documentation through OpenAPI and Swagger UI.
The goal is to build a portfolio project that demonstrates not only the ability to implement endpoints, but also the ability to reason about application structure, persistence, consistency, and testing.
Feature status reflects the current implementation and is subject to change as development progresses.
- User management.
- Authentication and authorization infrastructure.
- Role-based access control.
- Further refinement of role management and access policies.
- Product management.
- Category management.
- Brand management.
- Dynamic product filtering using Spring Data JPA Specifications.
- Further catalog capabilities and refinements.
- Customer module and its application structure.
- Complete and expand customer-facing use cases.
- Stock management foundation.
- Conditional stock updates to protect available quantities.
- Further inventory workflows and edge-case coverage.
- Shopping cart functionality.
- Checkout workflow foundation.
- Order creation as part of checkout.
- Transactional coordination of checkout operations.
- Expanded order lifecycle and sales scenarios.
- Centralized exception handling.
- Configurable application logging.
- Database migrations with Flyway.
- API documentation with OpenAPI/Swagger.
- Automated tests using JUnit, Mockito, RestAssured, and Testcontainers.
- Continuous integration workflow for running tests.
- Additional observability capabilities, such as metrics and distributed tracing, where not yet implemented.
- Payment processing.
SpringEcommerce follows the modular monolith architectural style. The application is deployed as a single unit, while its code is divided into modules organized around business capabilities.
Each module owns a specific area of the business. Within modules, packages separate concerns such as application services, domain models, persistence, HTTP controllers, and API documentation where appropriate.
This structure aims to keep related functionality together, make responsibilities easier to understand, and reduce unnecessary coupling without introducing the operational complexity of microservices.
SpringEcommerce
βββ iam
β βββ user
β βββ authentication
β βββ role
βββ catalog
β βββ brand
β βββ category
β βββ product
βββ customer
β βββ customer
βββ inventory
β βββ stock
βββ sales
β βββ cart
β βββ checkout
β βββ order
βββ config
β βββ openapi
β βββ security
βββ observability
β βββ logging
β βββ metrics
β βββ tracing
βββ shared
βββ exception
βββ pagination
βββ utils
The presence of a package in this structure does not necessarily mean every capability beneath it is complete.
For a deeper explanation of module responsibilities, internal organization, and dependencies, see Architecture.
| Technology | Purpose |
|---|---|
| Java 17 | Primary programming language |
| Spring Boot 3.4.0 | Application framework |
| Spring Web | REST API development |
| Spring Data JPA | Persistence and repository abstraction |
| Hibernate | ORM implementation |
| MySQL | Relational database |
| Flyway | Versioned database migrations |
| Spring Security | Authentication and authorization |
| OpenAPI / Swagger UI | API documentation |
| JUnit | Automated testing |
| Mockito | Test doubles and isolated unit tests |
| Spring Boot Test | Spring application testing |
| RestAssured | HTTP API testing |
| Testcontainers | Tests using containerized dependencies |
| GitHub Actions | Continuous integration |
The table describes the project's intended or established technology stack; individual integrations and their current coverage may vary as implementation progresses.
The project explores practical engineering techniques through concrete implementation choices.
- Modular organization: groups code around business capabilities instead of relying exclusively on technical layers across the entire application.
- Transactional checkout: coordinates related checkout operations within a database transaction to prevent partial completion when a transactional operation fails.
- Conditional stock updates: applies stock changes with an availability condition in the database update, helping protect stock quantity invariants when the update result is validated.
- Dynamic filtering: uses Spring Data JPA Specifications to compose product search criteria without requiring a separate repository method for every filter combination.
- Automated testing: combines unit tests with integration tests that exercise application and persistence behavior.
- Reusable test data: uses fixtures and Object Mother patterns to make test setup more consistent and readable.
- Versioned schema changes: uses Flyway migrations to track database evolution.
- API contract documentation: separates endpoint documentation from controller implementation through dedicated documentation interfaces where applicable.
These practices involve trade-offs rather than being universal solutions. Their motivations, alternatives, limitations, and implementation details are documented in Engineering Decisions.
The REST API is documented using OpenAPI, with Swagger UI providing an interactive interface for inspecting endpoints and trying requests.
When the application is running, the documentation is available at:
http://localhost:8080/swagger-ui/index.html
The OpenAPI specification is typically available at:
http://localhost:8080/v3/api-docs
These URLs assume the default port and standard Springdoc configuration. Actual availability depends on the active application configuration.
The API covers the project's identity, catalog, customer, inventory, and sales capabilities according to their implementation status.
For a quick, module-by-module endpoint index, see API Reference.
- JDK 17.
- Maven, or the project's Maven Wrapper if included in the repository.
- MySQL.
- Git.
git clone <repository-url>
cd springecommerceReplace <repository-url> with the repository's actual Git URL.
Create a MySQL database and configure the application's database connection using the project's supported configuration properties or environment variables.
For example, Spring Boot commonly uses the following properties:
spring.datasource.url=${DB_URL}
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}These are illustrative configuration entries, not a guarantee that the project currently defines these exact environment variable names. Match them to the actual application configuration before running the project.
Do not commit real credentials or secrets to version control.
If the Maven Wrapper is available:
./mvnw spring-boot:runOn Windows:
.\mvnw.cmd spring-boot:runAlternatively, with Maven installed:
mvn spring-boot:runEnsure the database is available and the connection settings are correct before starting the application.
For the exact environment variables, profiles, database setup, and development commands, see Development Guide.
The project uses automated tests to verify business behavior, application integration, and persistence-related scenarios.
- JUnit: test organization and assertions.
- Mockito: isolated tests using mocks and other test doubles.
- Spring Boot Test: integration with the Spring application context.
- RestAssured: HTTP request and response validation.
- Testcontainers: integration tests against containerized dependencies.
- Fixtures and Object Mother: reusable test data setup.
Tests are organized into separate areas for unit tests and integration tests. Integration tests also contain supporting configuration, fixtures, infrastructure setup, and test support utilities.
Current test scenarios focus particularly on shopping cart and checkout behavior. The scope should not be interpreted as complete coverage of every module or business rule.
Using the Maven Wrapper:
./mvnw testOn Windows:
.\mvnw.cmd testOr, with Maven installed:
mvn testSome integration tests may require Docker to be available if they use Testcontainers.
For test boundaries, conventions, data setup, and known coverage gaps, see Testing Strategy.
The repository separates business modules, shared support code, application configuration, database migrations, and automated tests.
springecommerce/
βββ src/
β βββ main/
β β βββ java/
β β β βββ .../
β β β βββ iam/
β β β βββ catalog/
β β β βββ customer/
β β β βββ inventory/
β β β βββ sales/
β β β βββ config/
β β β βββ observability/
β β β βββ shared/
β β βββ resources/
β β βββ db/
β β βββ migration/
β βββ test/
β βββ java/
β βββ .../
β βββ unittests/
β βββ integrationtests/
β βββ config/
β βββ fixture/
β βββ infrastructure/
β βββ support/
β βββ tests/
βββ docs/
βββ pom.xml
βββ README.md
Business modules use internal packages to organize their responsibilities. For example, the catalog's product component follows this structure:
product/
βββ application/
β βββ dto/
β βββ mapper/
β βββ service/
β βββ snapshot/
βββ domain/
β βββ exception/
β βββ model/
βββ infrastructure/
β βββ persistence/
β βββ specification/
βββ presentation/
βββ docs/
βββ filter/
βββ http/
The exact internal organization varies by component according to its needs; not every component necessarily contains every package shown above.
Database migrations are maintained under src/main/resources/db/migration. Test code is separated into unit and integration test areas to distinguish isolated behavior verification from tests involving application components and external dependencies.
For the full architectural explanation and the responsibilities of each module, see Architecture.
The documentation below provides deeper explanations of the project's architecture, implementation choices, testing approach, and operational concerns.
| Document | Description |
|---|---|
| Architecture | Modular monolith structure, module responsibilities, internal organization, and dependencies. |
| API Reference | Endpoints grouped by module, HTTP methods, parameters, permissions, and expected responses. |
| Engineering Decisions | Selected engineering decisions, their motivations, alternatives, trade-offs, and limitations. |
| Testing Strategy | Test types, tools, test data setup, integration testing approach, and known coverage gaps. |
| Data Modeling and Persistence | Data model, entity relationships, persistence strategy, database constraints, queries, and migrations. |
| Security | Authentication, authorization, JWT implementation, role-based access control, and endpoint protection. |
| Error Handling | Exception structure, centralized handling, HTTP status mapping, and error response format. |
| Observability | Application logging and the status of metrics, tracing, and other observability capabilities. |
| Development Guide | Local setup, configuration, database preparation, application execution, testing, and development workflow. |
This documentation is intended to explain not only how the application is organized and used, but also why specific implementation choices were made, what trade-offs they introduce, and where the current implementation has limitations.
Documentation is maintained alongside development and may identify capabilities as Implemented, In Progress, or Planned to distinguish the current state from future work.
The roadmap tracks the project's evolution toward a more complete e-commerce backend. Items are grouped by implementation status to distinguish existing capabilities from ongoing work and future improvements.
- Define and implement user blocking and unblocking rules, considering their impact on customer-related operations.
- Expand automated test coverage for catalog, inventory, customer, IAM, and JWT token generation and validation.
- Implement email delivery for system notifications.
- Implement product image management, including upload, storage, and retrieval.
- Extend order lifecycle management.
- Expand automated tests for business rules, edge cases, and failure scenarios.
- Complete the project's technical documentation.
- Implement payment processing and integrate it into the checkout workflow.
- Improve observability with application metrics and distributed tracing.
- Expand CI/CD automation and prepare a deployment workflow.
- Evaluate containerized application deployment and cloud hosting.
- Review performance, database queries, and data integrity as the application grows.
- Evaluate asynchronous processing and messaging where business requirements justify them.
- Add operational monitoring and health visibility.
- Improve resilience and concurrency handling in critical workflows.
- Document and validate architectural decisions as the system evolves.
The roadmap is subject to change as implementation progresses. Priorities will be guided by business requirements, technical findings, and the value of each improvement rather than by adopting technologies without a clear purpose.