https://github.com/refine-software/afrad-api
Afrad is a fully featured e-commerce API built by refine
https://github.com/refine-software/afrad-api
docker e-commerce gin golang rest-api
Last synced: 9 months ago
JSON representation
Afrad is a fully featured e-commerce API built by refine
- Host: GitHub
- URL: https://github.com/refine-software/afrad-api
- Owner: refine-software
- License: mit
- Created: 2025-05-31T16:41:51.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-08T20:58:37.000Z (9 months ago)
- Last Synced: 2025-07-08T21:42:46.822Z (9 months ago)
- Topics: docker, e-commerce, gin, golang, rest-api
- Language: Go
- Homepage:
- Size: 396 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Afrad API
Afrad is a RESTful API for a clothing e-commerce platform. It handles user authentication, product listings, cart management, order processing, and more.
---
## 🚀 Get Up and Running
### Prerequisites
- [Docker](https://www.docker.com/)
- [Docker Compose](https://docs.docker.com/compose/)
- [Goose](https://github.com/pressly/goose) (for migrations)
- [Air](https://github.com/air-verse/air) (for development)
- [Swag](https://github.com/swaggo/swag) (for development)
### Environment Variables
Create a `.env` file with the following required environment variables:
```env
# APP
PORT=8080
# use 'dev' for development and 'prod' for production
APP_ENV=dev
MAX_OTP_REQUESTS_PER_DAY=10
OTP_EXP_IN_MIN=5
# DB
DB_HOST="afrad_db"
DB_PORT=5432
DB_DATABASE="afrad_db"
DB_USERNAME="afrad_api"
DB_PASSWORD="afrad1020"
DB_SCHEMA=public
DATABASE_URL=postgres://afrad_api:afrad1020@localhost:5432/afrad_db?sslmode=disable
# S3
S3_ACCESS_KEY_ID=
S3_SECRET_ACCESS_KEY=
S3_REGION=
S3_BUCKET=
# Oauth 2.0
SESSION_KEY=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
# JWT
ACCESS_TOKEN_SECRET=
ACCESS_TOKEN_EXP_IN_MIN=
REFRESH_TOKEN_SECRET=
REFRESH_TOKEN_EXP_IN_DAYS=
# Hash
HASHING_SECRET=
# Email Service
EMAIL=
PASSWORD=
```
### Run the Project
1. **Run the API with docker**
```bash
make docker-run # for production
make docker-down # for production
make docker-dev # for development
make docker-dev-down # for development
```
2. **Run Migrations**
```bash
# You only need to run migrations once
make migrate-up
```
---
## 📦 API Features
- User Registration (Local + OAuth)
- Email Verification with OTP
- Login / Logout
- Password Reset
- Products and Categories
- Cart Management
- Orders and Checkout
- Admin Routes
---
## 🛠Project Structure
```
afrad-api/
├── cmd
│  └── api
├── config
│  └── config.go
├── docker-compose.dev.yml
├── docker-compose.yml
├── Dockerfile
├── Dockerfile.dev
├── docs
│  ├── docs.go
│  ├── swagger.json
│  └── swagger.yaml
├── go.mod
├── go.sum
├── internal
│  ├── auth
│  ├── database
│  ├── middleware
│  ├── models
│  ├── s3
│  ├── server
│  └── utils
├── Makefile
├── project-docs
│  ├── endpoints.md
│  ├── reposConventions.md
│  ├── schema.sql
│  └── TODO.md
└── README.md
```
---
## 📄 License
[](LICENSE)
This project is licensed under the [MIT License](LICENSE) © 2025 Refine Team.