A full-stack E-Commerce application built with Angular 18 and Spring Boot 3.
- Product Browsing β Filterable product listing with search, category filtering, and price range
- Product Detail β Rich product view with multiple images and add-to-cart
- Shopping Cart β Add, update quantity, remove items, and real-time cart totals
- Checkout β Select a shipping address from your address book and place orders
- Order History β Track past orders and their statuses
- JWT Authentication β Secure signup, sign-in, and protected routes
- OTP Verification β Phone number verification via Twilio SMS
- Address Book β Manage multiple shipping addresses (CRUD)
- Dashboard β Overview of the store
- Product Management β Create, edit, and delete products with image uploads
- Category Management β Full CRUD for product categories
- Order Management β View all orders and update order statuses
- Email Notifications β Order confirmation emails via Gmail SMTP
- SMS Notifications β OTP delivery via Twilio
- Global Exception Handling β Consistent API error responses
- Input Validation β Request DTO validation with Bean Validation
- CORS β Pre-configured for Angular dev server on
localhost:4200 - Responsive UI β Modern interface with CSS Grid/Flexbox
| Component | Technology |
|---|---|
| Framework | Spring Boot 3.2.1 |
| Language | Java 21 |
| Database | PostgreSQL |
| Security | Spring Security + JWT (jjwt 0.12) |
| Validation | Spring Boot Starter Validation |
| Spring Boot Starter Mail | |
| SMS | Twilio SDK 9.14 |
| Boilerplate | Lombok 1.18 |
| Build Tool | Maven |
| Component | Technology |
|---|---|
| Framework | Angular 18 |
| Language | TypeScript 5.5 |
| UI Library | Angular Material 18 + Angular CDK |
| Styling | Vanilla CSS (Grid / Flexbox) |
| JWT Handling | jwt-decode |
| Build Tool | Angular CLI |
ECommerce/
βββ backend/ # Spring Boot Application
β βββ src/main/java/com/ecommerce/
β β β
β β βββ common/ # ββ Shared Infrastructure ββ
β β β βββ config/ # SecurityConfig
β β β βββ security/ # JWT filter, token provider, CookieService
β β β βββ exception/ # BadRequestException, ResourceNotFoundException
β β β βββ handler/ # GlobalExceptionHandler
β β β βββ dto/ # ApiResponse
β β β
β β βββ auth/ # ββ π Auth Domain ββ
β β β βββ AuthController # /api/auth
β β β βββ AuthService (interface) # Signup, Signin
β β β βββ AuthServiceImpl # Implementation
β β β βββ SignInRequest, SignUpRequest, AuthResponse
β β β
β β βββ user/ # ββ π€ User Domain ββ
β β β βββ User (entity) # JPA entity
β β β βββ UserRepository # Data access
β β β βββ UserService (interface) # Centralized user access
β β β βββ UserServiceImpl # Implementation
β β β βββ HomeController # /
β β β
β β βββ product/ # ββ π¦ Product Domain ββ
β β β βββ ProductController # /api/products
β β β βββ ProductService + Impl # CRUD, search, filter
β β β βββ ImageService + Impl # Product image fetching
β β β βββ Product, ProductImage # JPA entities
β β β βββ ProductRepository # Data access
β β β βββ ProductRequest, ProductResponse
β β β
β β βββ category/ # ββ π Category Domain ββ
β β β βββ CategoryController # /api/categories
β β β βββ CategoryService + Impl # CRUD
β β β βββ Category # JPA entity
β β β βββ CategoryRepository # Data access
β β β βββ CategoryRequest, CategoryResponse
β β β
β β βββ cart/ # ββ π Cart Domain ββ
β β β βββ CartController # /api/cart
β β β βββ CartService + Impl # Add, update, remove, clear
β β β βββ Cart, CartItem # JPA entities
β β β βββ CartRepository, CartItemRepository
β β β βββ CartItemRequest, CartResponse
β β β
β β βββ order/ # ββ π Order Domain ββ
β β β βββ OrderController # /api/orders
β β β βββ OrderService + Impl # Create, cancel, track
β β β βββ Order, OrderItem, OrderStatus
β β β βββ OrderRepository # Data access
β β β βββ OrderRequest, OrderResponse
β β β
β β βββ address/ # ββ π Address Domain ββ
β β β βββ AddressController # /api/addresses
β β β βββ AddressService + Impl # CRUD + default management
β β β βββ Address # JPA entity
β β β βββ AddressRepository # Data access
β β β βββ AddressRequest, AddressResponse
β β β
β β βββ notification/ # ββ π Notification Domain ββ
β β βββ OtpController # /api/otp
β β βββ OtpService + Impl # OTP generate, send, verify
β β βββ OtpCleanupScheduler # Scheduled expired OTP cleanup
β β βββ EmailService + Impl # Transactional emails
β β βββ SmsService + Impl # Twilio SMS
β β βββ OrderEmailComposer # Order email templates
β β βββ Otp, OtpRepository # JPA entity + data access
β β βββ SendEmailRequest, SendSmsRequest
β β
β βββ .env.example # Template for environment variables
β βββ pom.xml
β
βββ frontend/ # Angular Application
β βββ src/app/
β β βββ core/
β β β βββ guards/ # Auth, Admin, HomeRedirect guards
β β β βββ interceptors/ # HTTP interceptors (JWT attach)
β β β βββ models/ # TypeScript interfaces / models
β β β βββ services/ # API services (auth, product, cart, order, β¦)
β β βββ features/
β β β βββ admin/ # Dashboard, ProductForm
β β β βββ auth/ # Login, Register
β β β βββ cart/ # Shopping cart page
β β β βββ checkout/ # Checkout flow
β β β βββ orders/ # Order history
β β β βββ products/ # Product list, Product detail
β β βββ shared/
β β βββ components/ # Header, Footer, ProductCard
β βββ package.json
β
βββ ECommerce_API.postman_collection.json # Postman collection for all endpoints
The backend is organized by business domain (vertical slicing), not by technical layer. Each domain package is self-contained with its own controller, service, entities, DTOs, and repositories β making it straightforward to extract into an independent microservice.
| Domain | Responsibility | API Prefix |
|---|---|---|
auth/ |
User registration & login | /api/auth |
user/ |
User entity & centralized access | β |
product/ |
Product catalog, search, images | /api/products |
category/ |
Product categories | /api/categories |
cart/ |
Shopping cart management | /api/cart |
order/ |
Order creation, tracking, cancellation | /api/orders |
address/ |
Shipping address book | /api/addresses |
notification/ |
Email, SMS, OTP verification | /api/otp |
| Principle | Implementation |
|---|---|
| Single Responsibility | OTP cleanup extracted to OtpCleanupScheduler; cookie logic to CookieService; email composition to OrderEmailComposer |
| Open/Closed | All services are interfaces with Impl classes β swap implementations without modifying consumers |
| Liskov Substitution | EmailService.sendOrderConfirmation uses OrderResponse (typed) instead of Object |
| Interface Segregation | Email composition separated from email sending; domain-specific concerns stay in their domain |
| Dependency Inversion | Controllers depend on service interfaces; UserService abstracts all user data access across domains |
- Node.js v18+
- Java JDK 21
- PostgreSQL (running instance)
- Maven 3.8+
-
Navigate to
backend/:cd backend -
Copy the example env file and fill in your values:
cp .env.example .env
-
Edit
.envwith your configuration:# Database DB_URL=jdbc:postgresql://localhost:5432/ecommerce DB_USERNAME=your_db_username DB_PASSWORD=your_db_password # JWT JWT_SECRET=YourSuperSecretKeyMustBeAtLeast256BitsLong # Email (Gmail App Password) SPRING_MAIL_USERNAME[email protected] SPRING_MAIL_PASSWORD=your_app_password # Twilio SMS (optional β required for OTP) TWILIO_ACCOUNT_SID=your_twilio_account_sid TWILIO_AUTH_TOKEN=your_twilio_auth_token TWILIO_PHONE_NUMBER=+1234567890
-
Build and run:
mvn clean install mvn spring-boot:run
The backend will start on
http://localhost:8080.
-
Navigate to
frontend/:cd frontend -
Install dependencies:
npm install
-
Start the dev server:
npm start
-
Open your browser at
http://localhost:4200.
| Role | Capabilities |
|---|---|
USER |
Browse products, manage cart, manage addresses, place orders |
ADMIN |
Create/edit/delete products & categories, view & update all orders |
Note: To promote a user to admin, manually update the
rolecolumn toADMINin theuserstable for the desired user.
| Endpoint | Access |
|---|---|
/api/auth/** |
Public |
GET /api/products/** |
Public |
/api/products/** |
Admin only (CUD operations) |
/api/categories/** |
Public |
/api/cart/** |
Authenticated users (USER) |
/api/orders/** |
Authenticated users (USER) |
/api/addresses/** |
Authenticated users (USER) |
A complete Postman collection is provided at the project root:
ECommerce_API.postman_collection.json
Import this file into Postman to explore and test all endpoints.
- Domain-Driven Structure β Each backend domain is a self-contained module with its own controller, service interface, implementation, entities, repositories, and DTOs. This enables clean microservice extraction when needed.
- Service Interfaces β All business logic is behind interfaces (
CartService,OrderService, etc.) with correspondingImplclasses, following OCP and DIP. - UserService Abstraction β
UserRepositoryis only accessed within theuser/package. All other domains use theUserServiceinterface, reducing coupling. - Long userId Pattern β Service methods accept
Long userIdinstead of the fullUserentity. Controllers extract the ID from@AuthenticationPrincipaland pass only the ID downstream. - Standalone Components β The Angular frontend uses standalone components with lazy-loaded routes (no NgModules).
- Global Error Handling β
GlobalExceptionHandlerreturns structured error responses forResourceNotFoundException,BadRequestException, and validation errors. - Environment Variables β Spring Boot loads configuration from
backend/.envviaspring.config.import. See.env.examplefor all required keys.