afrad-api

module
v0.0.0-...-447df18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2025 License: MIT

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
Environment Variables

Create a .env file with the following required environment variables:

# 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
make docker-run # for production
make docker-down # for production

make docker-dev # for development
make docker-dev-down # for development
  1. Run Migrations
# 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

This project is licensed under the MIT License Β© 2025 Refine Team.

Directories ΒΆ

Path Synopsis
cmd
api command
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
internal
database
Package database provides access to the application's PostgreSQL database and defines the service layer for interacting with various data repositories.
Package database provides access to the application's PostgreSQL database and defines the service layer for interacting with various data repositories.
s3
server
Package server handles starting the HTTP server and routing.
Package server handles starting the HTTP server and routing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL