Skip to content

wasifsarwar/gocart

Repository files navigation

GoCart - Full-Stack E-commerce API

Go Go Version API Documentation License Netlify Status

A modern, scalable microservices-based e-commerce API built with Go, featuring comprehensive testing, CI/CD, and beautiful API documentation.

Live Demo - Deployed on Netlify

GoCart E-commerce Platform - Experience the full-featured shopping platform with real-time product browsing, user management, and order processing!

Live API Documentation

Interactive API Explorer - Test APIs directly in your browser

Service-Specific Documentation


Architecture Overview

GoCart implements a microservices architecture with the following services:

Frontend Stack

  • React 18 with TypeScript
  • React Router for navigation
  • Custom hooks for state management
  • Responsive CSS with mobile-first design
  • Real-time search & sorting
  • Animated gopher branding

Implemented Services

Service Endpoint Status Description
Product Service /products Complete Product catalog, inventory, CRUD operations
User Service /users Complete User management, authentication, profiles
Order Service /orders Complete Order processing and management

All services run on single port

Planned Services

  • Payment Service - Payment processing simulation
  • Notification Service - Email/SMS notifications

Quick Start

Prerequisites

  • Go 1.23+
  • PostgreSQL 13+
  • Docker & Docker Compose (optional)

1. Clone & Setup

git clone https://github.com/wasifsarwar/gocart.git
cd gocart
go mod download

2. Database Setup

# Start PostgreSQL with Docker
docker-compose up -d postgres

# Or use your local PostgreSQL
createdb gocart_db
# Shut down PostgreSQL instance
brew services stop postgresql

3. Run Services

Option A: Run All Services (Single Port)

go run cmd/main.go

Unified API: http://localhost:8080

ℹ️ When the backend boots successfully it automatically migrates the schema and seeds the database with the sample catalog/users defined under pkg/seeder/data. You’ll see the seeding summary in the logs—no additional command is required for local development.

Option B: Docker Compose

# Start all services
docker-compose up

# Build and start
docker-compose up --build

# Stop all services
docker-compose down

# View logs
docker-compose logs app      # Backend logs

Option C: Bash startup script

# Start everything with one command
./start.sh

4. Preload Sample Data Without Running the API

Need a filled database before you launch the backend? Run the dedicated seeding command:

go run ./cmd/seed

This connects to the configured Postgres instance, migrates schemas, and loads the sample products/users defined in pkg/seeder/data/*.yaml. Feel free to tweak those YAML files (e.g., adjust prices or categories) and rerun the command whenever you need a fresh dataset.


API Endpoints

Product Service

GET    /products           # List all products
POST   /products           # Create product
GET    /products/{id}      # Get product by ID
PUT    /products/{id}      # Update product
DELETE /products/{id}      # Delete product

User Service

GET    /users              # List all users
POST   /users/register     # Register new user
POST   /users/login        # Login user
GET    /users/{id}         # Get user by ID
PUT    /users/{id}         # Update user
DELETE /users/{id}         # Delete user

Order Service

GET    /orders             # List all orders
POST   /orders             # Create new order
GET    /orders/{id}        # Get order by ID
PUT    /orders/{id}        # Update order
DELETE /orders/{id}        # Delete order
GET    /orders/user/{user_id} # Get orders by user ID
DELETE /orders/{id}/items  # Delete order item

Testing

Run All Tests

go test ./...

About

e-commerce API written in go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •