Loading repository data…
Loading repository data…
prasadus92 / repository
A production-grade RESTful API for e-commerce operations built with modern Java and Spring Boot best practices.
A production-grade RESTful API for e-commerce operations built with modern Java and Spring Boot best practices.
| Category | Technology |
|---|---|
| Language | Java 21 (LTS) |
| Framework | Spring Boot 3.3.5 |
| Database | PostgreSQL 16 / H2 (dev) |
| ORM | Spring Data JPA / Hibernate |
| Build | Maven |
| API Docs | springdoc-openapi 2.6 |
| Caching | Caffeine |
| Testing | JUnit 5, Testcontainers, REST Assured |
| CI/CD | GitHub Actions |
| Container | Docker with multi-stage builds |
# Clone the repository
git clone https://github.com/prasadus92/ecommerce-store.git
cd ecommerce-store
# Build the project
mvn clean install
# Run the application
mvn spring-boot:run
The API will be available at http://localhost:8080
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f ecommerce-api
# Stop services
docker-compose down
Once the application is running, access the interactive API documentation:
| Method | Endpoint | Description |
|---|---|---|
GET | /api/v1/products | List all products (paginated) |
GET | /api/v1/products/{id} | Get product by ID |
POST | /api/v1/products | Create a new product |
PUT | /api/v1/products/{id} | Update a product |
DELETE | /api/v1/products/{id} | Deactivate a product |
| Method | Endpoint | Description |
|---|---|---|
GET | /api/v1/orders | List all orders (paginated, filterable) |
GET | /api/v1/orders/{id} | Get order by ID |
POST | /api/v1/orders | Place a new order |
PATCH | /api/v1/orders/{id}/status | Update order status |
POST | /api/v1/orders/{id}/cancel | Cancel an order |
Create a Product:
curl -X POST http://localhost:8080/api/v1/products \
-H "Content-Type: application/json" \
-d '{
"name": "iPhone 15 Pro",
"description": "Latest flagship smartphone",
"price": 999.99,
"sku": "IPHONE-15-PRO"
}'
Place an Order:
curl -X POST http://localhost:8080/api/v1/orders \
-H "Content-Type: application/json" \
-d '{
"buyerEmail": "customer@example.com",
"items": [
{"productId": "uuid-here", "quantity": 2}
]
}'
Get Orders by Date Range:
curl "http://localhost:8080/api/v1/orders?startDate=2024-01-01&endDate=2024-12-31"
src/
├── main/
│ ├── java/com/ecommerce/store/
│ │ ├── api/
│ │ │ ├── controller/ # REST controllers
│ │ │ ├── dto/ # Request/Response DTOs (Java records)
│ │ │ ├── exception/ # Global exception handling
│ │ │ └── mapper/ # MapStruct mappers
│ │ ├── config/ # Configuration classes
│ │ └── domain/
│ │ ├── entity/ # JPA entities
│ │ ├── exception/ # Domain exceptions
│ │ ├── repository/ # Spring Data repositories
│ │ └── service/ # Business logic
│ └── resources/
│ ├── application.yml # Development config
│ └── application-production.yml # Production config
└── test/
└── java/com/ecommerce/store/
├── domain/service/ # Unit tests
└── integration/ # Integration tests with Testcontainers
| Variable | Description | Default |
|---|---|---|
DB_HOST | Database host | postgres |
DB_PORT | Database port | 5432 |
DB_NAME | Database name | ecommerce_db |
DB_USER | Database username | ecommerce_user |
DB_PASSWORD | Database password | secret |
SERVER_PORT | Application port | 8080 |
JAVA_OPTS | JVM options | See Dockerfile |
# Run all tests
mvn test
# Run with coverage report
mvn verify
# Coverage report location
open target/site/jacoco/index.html
| Endpoint | Description |
|---|---|
/actuator/health | Application health status |
/actuator/info | Application information |
/actuator/metrics | Application metrics |
/actuator/prometheus | Prometheus-format metrics |
{
"status": "UP",
"components": {
"db": {"status": "UP"},
"diskSpace": {"status": "UP"}
}
}
The API uses RFC 7807 Problem Details for error responses:
{
"type": "https://api.ecommerce.com/errors/not-found",
"title": "Resource Not Found",
"status": 404,
"detail": "Product not found with identifier: abc123",
"timestamp": "2024-01-15T10:30:00Z",
"resourceType": "Product",
"identifier": "abc123"
}
For production deployment, consider adding:
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.