Full-featured REST API backend for the SK Store e-commerce platform, built with Spring Boot. This is the fleshed-out version of the backend β JWT + Google OAuth2 auth, an admin panel, and full product/cart/order/review flows are all wired up end-to-end.
π Frontend: E-com-new Β· πLive demo
This service is the API layer for the SK Store storefront. Customers can browse products/categories, manage a cart and wishlist, place and track orders, leave reviews, and manage their profile/addresses. Admins get a separate login and dashboard for managing customers, orders, and reviews.
β Status: Actively developed. Core commerce flows (auth, catalog, cart, wishlist, orders, reviews, addresses) are implemented end-to-end; automated test coverage is still minimal.
| Category | Library |
|---|---|
| β Language | Java 21 |
| π± Framework | Spring Boot 4.1.0 |
| π Web | Spring Web MVC (spring-boot-starter-webmvc) |
| ποΈ Persistence | Spring Data JPA (+ JPA Specifications for filtering) |
| π Database | PostgreSQL |
| π Security | Spring Security, BCrypt password hashing |
| π Auth | JWT (jjwt 0.12.7) + Google OAuth2 login |
| π API Docs | springdoc-openapi / Swagger UI |
| β Validation | Spring Boot Validation |
| β¨ Boilerplate | Lombok |
| π Monitoring | Spring Boot Actuator |
| π¨ Build Tool | Maven (with Maven Wrapper) |
| π³ Containerization | Docker (multi-stage build) |
| βοΈ CI/CD | GitHub Actions β Azure Web App |
E-com-Updated-Backend/
βββ .github/workflows/ # CI/CD β build & deploy to Azure Web App
βββ .mvn/wrapper/ # Maven wrapper files
βββ src/
β βββ main/java/Sathish292004/
β β βββ config/ # Security, CORS, Swagger, password encoder
β β βββ controller/ # REST controllers
β β βββ dto/
β β β βββ request/ # Request payloads
β β β βββ response/ # Response payloads
β β βββ exception/ # Custom exceptions + global handler
β β βββ model/ # JPA entities
β β βββ repository/ # Spring Data JPA repositories
β β βββ security/ # JWT filter/service, OAuth2 success handler
β β βββ service/ # Business logic
β β βββ specification/ # Dynamic product filtering (JPA Specifications)
β β βββ SpringEcomApplication.java
β βββ main/resources/
β β βββ application.properties
β βββ test/java/Sathish292004/
βββ Dockerfile # Multi-stage build (Maven β JRE 21)
βββ mvnw / mvnw.cmd # Maven wrapper scripts
βββ pom.xml
- Java 21 (JDK)
- PostgreSQL (local instance or remote)
- A Google OAuth2 Client ID/Secret (see note below)
- Maven not required β the project includes the Maven Wrapper (
mvnw)
This app reads config from environment variables, not hardcoded defaults in application.properties. All five must be set, or Spring Boot will fail to start (the placeholders can't resolve otherwise):
| Variable | Description |
|---|---|
DB_URL |
JDBC URL, e.g. jdbc:postgresql://localhost:5432/ecom |
DB_USERNAME |
PostgreSQL username |
DB_PASSWORD |
PostgreSQL password |
GOOGLE_CLIENT_ID |
Google OAuth2 client ID |
GOOGLE_CLIENT_SECRET |
Google OAuth2 client secret |
export DB_URL=jdbc:postgresql://localhost:5432/ecom
export DB_USERNAME=your_db_username
export DB_PASSWORD=your_db_password
export GOOGLE_CLIENT_ID=your_google_client_id
export GOOGLE_CLIENT_SECRET=your_google_client_secretHibernate is set to ddl-auto=update, so tables are created/updated automatically on startup.
git clone https://github.com/Sathish292004/E-com-Updated-Backend.git
cd E-com-Updated-Backend
# Run with the Maven wrapper
./mvnw spring-boot:run # macOS/Linux
mvnw.cmd spring-boot:run # Windows
# Or build a jar and run it
./mvnw clean package -DskipTests
java -jar target/*.jarThe API starts on port 8080 by default.
docker build -t ecom-backend .
docker run -p 8080:8080 \
-e DB_URL=jdbc:postgresql://host.docker.internal:5432/ecom \
-e DB_USERNAME=your_db_username \
-e DB_PASSWORD=your_db_password \
-e GOOGLE_CLIENT_ID=your_google_client_id \
-e GOOGLE_CLIENT_SECRET=your_google_client_secret \
ecom-backendThe Dockerfile does a multi-stage build: it compiles with Maven on maven:3.9.8-eclipse-temurin-21, then runs the resulting jar on a lightweight eclipse-temurin:21-jre image.
Interactive Swagger UI (with a "bearer token" authorize button for JWTs) is available once the app is running:
http://localhost:8080/swagger-ui.html
Raw OpenAPI spec: GET http://localhost:8080/v3/api-docs
GET http://localhost:8080/actuator/health
There are two user types, distinguished by role (CUSTOMER / ADMIN) and enforced with Spring Security:
| Flow | Endpoint | Notes |
|---|---|---|
| Customer register | POST /api/auth/register |
Creates a customer, password hashed with BCrypt |
| Customer login | POST /api/auth/login |
Returns a JWT |
| Customer Google login | GET /oauth2/authorization/google |
Auto-creates a customer on first login, redirects to the frontend with a JWT |
| Admin login | POST /api/admin/login |
Returns a JWT with the ADMIN role |
Protected endpoints expect:
Authorization: Bearer <token>
| Module | Base path | Access |
|---|---|---|
| Customer auth | /api/auth/** |
Public |
| Admin auth | /api/admin/login |
Public |
| Products & categories | /api/products/**, /api/product/**, /api/categories, /api/category/** |
Public browsing/search |
| Cart, wishlist, addresses, profile | /api/customer/** |
CUSTOMER role |
| Orders | /api/orders/** |
Authenticated |
| Reviews | /api/products/{id}/reviews, /api/customer/products/{id}/reviews |
Reading needs auth; posting needs CUSTOMER role |
| Admin dashboard, customers, orders, reviews | /api/admin/** |
ADMIN role |
- π Product, category, cart, wishlist & order entities
- π JWT + Google OAuth2 authentication, role-based access
- π§Ύ Cart, wishlist, and order management endpoints
- π API documentation via Swagger / OpenAPI
- π§ͺ Real test coverage (currently just a context-load smoke test)
- π³ Payment gateway integration
- πΌοΈ Move product images out of the DB into object storage
Sathish Kumar B
π GitHub: github.com/Sathish292004
β If you found this useful, consider giving the repo a star!