Ecommerce website based on microservices architecture in spring boot 3
- This project contains backend APIs for ecommerce with different microservices
- It contains all the functionalities like product inventory, variance, cart, checkout, websockets etc
- All the APIs are constructed with Spring boot 3
https://www.postman.com/galactic-eclipse-361945/workspace/public-9372/collection/1877749-6742d038-c937-4aac-838e-7e30ff85865d?action=share&creator=1877749 In Postman use the below url to recieve server side events
ws://localhost:8091/ws/events - Authentication with Jwt
- Add/remove products
- Create categories with hierarchy
- Manage address
- Feature template
- Shopping cart
- Checkout page
- Server Events page
- Java 17
- Spring boot 3
- Elasticsearch 8
- Spring data JPA
- Postgres 14
- Spring cloud gateway
- Docker (docker-compose)
https://localhost:8091
| Service | Base URL |
|---|---|
| User | https://localhost:8080/api |
| Product | https://localhost:8081/api |
| Cart | https://localhost:8082/api |
| Order | https://localhost:8083/api |
| Type | Endpoint |
|---|---|
| Api docs | /api/docs |
| Swagger UI | /swagger-ui |
- Clone repository
git clone git@github.com:amol9372/ecommerce-spring-boot-backend-apis.git- Set docker & elastic search credentials
./.env and set the Postgres & ElasticSearch credentials- Go to
ecomm-dband set the postgres credentials in Dockerfile. Also make sure postgres-data folder is present.
./ecomm-db/Dockerfile -rw-r--r--@ 1 amolsingh staff 139 5 Feb 19:15 Dockerfile -rw-r--r--@ 1 amolsingh staff 9408 5 Feb 19:15 ecomm.sql drwxr-xr-x@ 2 amolsingh staff 64 5 Feb 19:16 postgres-data drwxr-xr-x@ 5 amolsingh staff 160 5 Feb 19:16 . drwxr-xr-x@ 14 amolsingh staff 448 5 Feb 19:44 ..- Run the docker compose command
./start-services.sh- Create elastic search index
productv1using the following command
./create-index.shImport above postman collection (create a fork also) and lets do the basic setup
- Use the
/auth/registerAPI to register user in the application - The above user will have
USERrole. - Admin user is already created in the application with below credentials in
userstable
| password | |
|---|---|
| admin@example.com | password |
Use the /auth/login API to authenticate user and get the credentials (jwt token + userinfo)
{ "token": "eyJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImFkbWluQGV4YW1wbGUuY29tIiwicm9sZXMiOlsiQURNSU4iXSwic3ViIjoiYXBwfDk4ZWI2NzRkYTdjNzMzYjIxYWMwZTBkYiIsImlhdCI6MTcwNzMxODY2MywiZXhwIjoxNzA3MzI1ODYzfQ.qEulnxe9IQfOFzO-6F1l81kvy61cNvo4ub3MdurX1Ec", "userInfo": { "sub": "app|98eb674da7c733b21ac0e0db", "name": "admin@example.com", "picture": null, "email": "admin@example.com", "nickname": "admin", "email_verified": false } }Use the token as in Authorization header for all APIs
Header values are set in collection variables
- Authorization (with bearer token)
- x-token-type (default as
app)
As a part of starting docker containers, reference data is already created in below entities:
| Entity | API | DB Table |
|---|---|---|
| Category | /admin/category | category |
| Feature Template | /admin/feature-template/{categoryId} | feature_template |
| Variant Features | /admin/variant/{categoryId} | master_variant |
The application uses the concept of feature templates & product variants
A feature template is a list of base line features which a product has eg - A laptop will have base features as
| Feature | Details |
|---|---|
| Brand | Apple |
| Model Name | MacBook Pro |
| Screen Size | 14.2 Inches |
| CPU Model | Unknown |
| Operating System | Mac OS |
| Special Feature | Fingerprint Reader |
| Graphics Card Description | Integrated |
Out of these features, only few can be a part of variant features. Variant features are basically what distinguishes the different SKUs of a product like color, storage, memory etc
An example of variant features
| Feature | Details |
|---|---|
| RAM Memory Installed Size | 8 GB |
| Colour | Silver |
| Hard Disk Size | 512 GB |
