https://github.com/paw1a/ecommerce-api
Rest api of e-commerce web application
https://github.com/paw1a/ecommerce-api
api ecommerce gin go jwt react rest rest-api swagger
Last synced: 3 months ago
JSON representation
Rest api of e-commerce web application
- Host: GitHub
- URL: https://github.com/paw1a/ecommerce-api
- Owner: paw1a
- Created: 2022-01-01T19:44:21.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-05T15:42:48.000Z (almost 4 years ago)
- Last Synced: 2025-05-07T01:40:46.276Z (11 months ago)
- Topics: api, ecommerce, gin, go, jwt, react, rest, rest-api, swagger
- Language: Go
- Homepage:
- Size: 3.64 MB
- Stars: 34
- Watchers: 1
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-golang-repositories - ecommerce-api - commerce web application (Repositories)
README
# E-commerce Rest API
API for web stores to sell different types of products. Integrated with payment system Stripe. Also has admin dashboard.

### [Swagger API documentation](https://app.swaggerhub.com/apis-docs/paw1a/E-commerce)
# Contents
1. [Run](#Run)
2. [API](#API)
3. [Implementation](#Implementation)
# Run
To run application you need:
- docker-compose
- .env file
## Env configuration
To run API locally you should create your own .env file in the root directory or rename `.env-example` to `.env`
Example `.env`:
```env
HOST=localhost
PORT=8080
STRIPE_KEY=
JWT_SECRET=jwtSecret
DB_NAME=ecommerce
DB_URI=mongodb://mongo:27017
DB_USERNAME=
DB_PASSWORD=
TEST_DB_NAME=ecommerce-test
TEST_DB_URI=mongodb://localhost:27017
TEST_DB_USERNAME=
TEST_DB_PASSWORD=
REDIS_URI=redis:6379
```
## Local run
```
make run
```
or
```
docker-compose up
```
Run test data generation for MongoDB
```
make init
```
Run frontend only
```
docker-compose up frontend
```
# API
Base url: `:8080/api/v1/`
API documentation can be found [here](https://app.swaggerhub.com/apis-docs/paw1a/E-commerce)
# Implementation
- REST API
- Clean architecture design
- Using MongoDB as a main data storage
- Using Redis for cache and user session storage
- Env based application configuration
- Automatically generated Swagger API docs
- Run with docker-compose
- Full automated CI/CD process
- Configured deploy to AWS
- React.js frontend (*in progress*)
- Stripe API payment integration
### Project structure
```
.
├── .bin // app binary files
├── .data // directory to store local db data
├── .github // github actions ci/cd directory
├── cmd // entry point
├── db // db generation scripts for mongo
├── deploy // deploy docker files
├── docs // swagger docs and readme images
├── frontend // react.js app directory
├── internal
│ ├── app // main application package
│ ├── config // config loading utils
│ ├── delivery // http handlers layer
│ ├── domain // all business entities and dto's
│ ├── repository // database repository layer
│ └── service // business logic services layer
├── pkg
│ ├── auth // jwt auth utils
│ ├── database // database connection utils
│ ├── logging // logger configuration
│ └── payment // payment service configuration
└─
```
# Diagram
