# README
E-Commerce Backend API
This project is a RESTful API for an e-commerce platform, developed as part of the backend internship technical test for PT Synapsis Sinergi Digital.
Features
- Product listing by category
- Shopping cart management (add, view, delete items)
- Checkout and payment processing
- User authentication (login and registration)
Tech Stack
- Go (Golang)
- Echo framework
- GORM (ORM)
- PostgreSQL
- Docker
Getting Started
Prerequisites
- Go 1.16+
- Docker and Docker Compose
- PostgreSQL (if running locally)
Installation
- Clone the repository:
git clone https://github.com/adrianramadhan/synpasis-ecommerce-api
- Navigate to the project directory:
cd synpasis-ecommerce-api
- Install dependencies:
go mod tidy
- Set up environment variables:
cp .env.example .env
- Migrate Database Schema:
go run main.go migrate
- Start REST Server
go run main.go rest
Running with Docker
- Build and run the containers:
docker-compose up --build
- The API will be available at
http://localhost:8080
Database Schema
Entity Relationships:
- User - Cart: One-to-Many (one user can have multiple shopping carts)
- User - Order: One-to-Many (one user can create multiple orders)
- Category - Product: One-to-Many (one category can have multiple products)
- Cart - CartItem: One-to-Many (one cart can have multiple items)
- Product - CartItem: One-to-Many (one product can be in multiple cart items)
- Cart - Order: One-to-One (one cart can become one order)
- Order - Payment: One-to-One (one order has one payment)
Flowchart
flowchart TD
subgraph User Journey
A[User Registration] --> B[User Login]
B --> C[Browse Products by Category]
C --> D[Add Products to Cart]
D --> E[View/Edit CartItems]
E --> F[Checkout]
F --> G[Cart Converted to Order]
G --> H[Make Payment]
end
subgraph Order Management
G --> I[Order Status Updated]
H --> J[Payment Status Updated]
end
subgraph Data Relationships
User -- "One-to-Many" --> Cart
User -- "One-to-Many" --> Order
Category -- "One-to-Many" --> Product
Cart -- "One-to-Many" --> CartItem
Product -- "One-to-Many" --> CartItem
Cart -- "One-to-One" --> Order
Order -- "One-to-One" --> Payment
end
Business Process Flow:
- User registers and logs into the application.
- User views Products based on Categories.
- User adds Products to the Cart, creating CartItems.
- User can view and edit CartItems within their Cart.
- When the User checks out, the Cart is converted into an Order.
- User makes a Payment for that Order.
- Order and Payment statuses are updated according to the transaction progress
Docker Image
The Docker image for this project is available on Docker Hub:
https://hub.docker.com/r/adrianramadhan/ecommerce-api/tags
Contributing
This project is for demonstration and technical test purposes. However, feedback and suggestions are welcome.
Contact
Adrian Putra Ramadhan - [email protected]