A blueprint for the system
Service | Responsibility | Database | Protocol |
---|---|---|---|
1. User Service | Auth, profiles, roles. | PostgreSQL | REST/JWT |
2. Product Service | Product catalog, categories, inventory. | MongoDB | REST/gRPC |
3. Cart Service | Shopping cart management. | Redis | REST |
4. Order Service | Order creation, status tracking. | PostgreSQL | REST+Kafka |
5. Paymet Service | Payments (Stripe/PayPal integration). | PostgreSQL | REST |
6. Shipping Service | Shipping cost calculation, tracking. | PostgreSQL | REST |
7. Notification Service | Emails/SMS (order confirmations). | MongoDB | Kafka |
8. Search Service | Elasticsearch-powered product search. | Elasticsearch | REST |
This service handles user profile, authentication, and role management.
Endpoint | Method | Description | Auth Required |
---|---|---|---|
/api/auth/register | POST | Register new user | No |
/api/auth/login | POST | Login (returns JWT) | No |
/api/users/me | GET | Get current user profile | YES |
/api/users/{id} | PUT | Update user details | Yes (owner/admin) |
/api/admin/users | GET | List all users (admin only) | Yes (admin) |
Curl commands:
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"testuser","password":"testpass"}'
PostgreSQL install:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install postgresql
brew services start postgresql
Create postgre db:
createuser -s -P postgres
psql -U postgres
-- Create database
CREATE DATABASE shop;
-- List all DB
\l
-- Create a user
CREATE USER shop_user WITH PASSWORD 'secret';
-- Create a database
CREATE DATABASE shop;
-- Give your user access
GRANT ALL PRIVILEGES ON DATABASE shop TO shop_user;
-- log into shop database using shop_user account
psql -U shop_user -d shop
install maven:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install maven
start spring boot:
mvn spring-boot:run
Ppstgres start and stop:
brew services start postgresql
brew services restart postgresql@14