Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/letsmakecakes/ecommerce-api
A robust and scalable e-commerce API built with Go, featuring user authentication, product management, shopping cart functionality, and secure payment processing with Stripe integration.
https://github.com/letsmakecakes/ecommerce-api
api database gin gin-gonic go golang gorm jwt orm postgresql sql stripe webhook
Last synced: 4 days ago
JSON representation
A robust and scalable e-commerce API built with Go, featuring user authentication, product management, shopping cart functionality, and secure payment processing with Stripe integration.
- Host: GitHub
- URL: https://github.com/letsmakecakes/ecommerce-api
- Owner: letsmakecakes
- Created: 2025-01-16T15:03:41.000Z (6 days ago)
- Default Branch: master
- Last Pushed: 2025-01-16T16:00:42.000Z (6 days ago)
- Last Synced: 2025-01-16T17:25:13.100Z (6 days ago)
- Topics: api, database, gin, gin-gonic, go, golang, gorm, jwt, orm, postgresql, sql, stripe, webhook
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# E-Commerce API
A robust and scalable e-commerce API built with Go, featuring user authentication, product management, shopping cart functionality, and secure payment processing with Stripe integration.
## ๐ Features
- **User Management**
- JWT-based authentication
- Role-based access control (Admin/User)
- Secure password handling- **Product Management**
- Product creation and management (Admin)
- Product search and filtering
- Inventory tracking- **Shopping Cart**
- Add/remove products
- Update quantities
- Cart persistence- **Order Processing**
- Order creation and management
- Multiple order statuses
- Order history- **Payment Integration**
- Secure payment processing with Stripe
- Payment status tracking
- Refund handling- **Admin Dashboard**
- Product management
- Order management
- User management
- Inventory control## ๐ ๏ธ Technical Stack
- **Backend**: Go 1.21+
- **Framework**: Gin-Gonic
- **Database**: PostgreSQL
- **ORM**: GORM
- **Authentication**: JWT
- **Payment**: Stripe
- **Documentation**: Swagger/OpenAPI
- **Containerization**: Docker## ๐ Prerequisites
- Go 1.21 or higher
- PostgreSQL 13 or higher
- Docker & Docker Compose (optional)
- Stripe Account (for payment processing)## ๐ง Installation
1. Clone the repository:
```bash
git clone https://github.com/letsmakecakes/ecommerce-api
cd ecommerce-api
```2. Install dependencies:
```bash
go mod download
```3. Set up environment variables:
```bash
cp .env.example .env
# Edit .env with your configuration
```4. Run database migrations:
```bash
go run cmd/migrate/main.go up
```5. Start the server:
```bash
go run cmd/api/main.go
```## ๐ณ Docker Setup
1. Build and run with Docker Compose:
```bash
docker-compose up --build
```2. The API will be available at `http://localhost:8080`
## ๐ Environment Variables
```env
# Server Configuration
SERVER_PORT=8080
SERVER_ENV=development# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=ecommerce
DB_USER=postgres
DB_PASSWORD=your_password# JWT Configuration
JWT_SECRET=your_jwt_secret
JWT_EXPIRY=24h# Stripe Configuration
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
```## ๐ API Documentation
API documentation is available at `/swagger/index.html` when running in development mode.
### Key Endpoints
```
POST /api/v1/auth/register # Register new user
POST /api/v1/auth/login # Login user
GET /api/v1/products # List products
POST /api/v1/cart/items # Add item to cart
POST /api/v1/orders # Create order
POST /api/v1/orders/:id/pay # Process payment# Admin Routes
POST /api/v1/admin/products # Create product
PUT /api/v1/admin/products/:id # Update product
GET /api/v1/admin/orders # List all orders
```## ๐งช Testing
Run all tests:
```bash
go test ./...
```Run specific test:
```bash
go test ./internal/domain/services -v
```## ๐ฆ Project Structure
```
๐ฆ ecommerce-api
โโโ cmd/ # Application entrypoints
โโโ internal/ # Private application code
โ โโโ api/ # API layer
โ โโโ domain/ # Business logic
โ โโโ platform/ # External services
โ โโโ repository/ # Data access
โโโ pkg/ # Public libraries
โโโ migrations/ # Database migrations
โโโ docs/ # Documentation
```## ๐ Security
- All passwords are hashed using bcrypt
- JWT tokens are used for authentication
- HTTPS enforced in production
- Input validation on all endpoints
- Role-based access control
- Rate limiting on sensitive endpoints## ๐ค Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ฅ Authors
- Your Name - [@letsmakecakes](https://github.com/letsmakecakes)
## ๐ Acknowledgments
- [Gin-Gonic](https://github.com/gin-gonic/gin)
- [GORM](https://gorm.io)
- [JWT-Go](https://github.com/golang-jwt/jwt)
- [Stripe Go Library](https://github.com/stripe/stripe-go)