Skip to content

Uranury/RBK_finalProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

30 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CS:GO Skin Marketplace API ๐ŸŽฎ

Go Version Docker PostgreSQL Redis

GitHub LinkedIn

A comprehensive marketplace API for buying and selling CS:GO skins, built with Go, featuring user authentication, transaction management, automated invoice generation, and email notifications.

๐ŸŽฏ Quick Start

# Clone and setup
git clone <repository-url>
cd finalProject

# Minimal setup (only 2 required variables!)
cp env.example .env
echo "JWT_SECRET=your-secret-key-here" >> .env
echo "MIGRATIONS_PATH=./migrations" >> .env

# Run with Docker
docker-compose up --build

Access: http://localhost:8080 | API Docs: http://localhost:8080/swagger/index.html

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   API Server    โ”‚    โ”‚   Worker        โ”‚    โ”‚   Database      โ”‚
โ”‚   (Gin)         โ”‚    โ”‚   (Asynq)       โ”‚    โ”‚   (PostgreSQL)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Redis         โ”‚    โ”‚   Email Service โ”‚    โ”‚   Migrations    โ”‚
โ”‚   (Queue)       โ”‚    โ”‚   (Mailgun)     โ”‚    โ”‚   (Golang)      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Tech Stack

Category Technology
Language Go 1.23.1
Framework Gin (HTTP server)
Database PostgreSQL 16
Cache/Queue Redis 7
ORM SQLx
Auth JWT
Background Jobs Asynq
Email Mailgun
PDF gofpdf
Docs Swagger/OpenAPI
Containerization Docker & Docker Compose

๐Ÿ“ Project Structure

finalProject/
โ”œโ”€โ”€ cmd/                    # Application entry points
โ”‚   โ”œโ”€โ”€ api/               # API server
โ”‚   โ””โ”€โ”€ worker/            # Background worker
โ”œโ”€โ”€ internal/              # Application code
โ”‚   โ”œโ”€โ”€ auth/              # Authentication
โ”‚   โ”œโ”€โ”€ handlers/          # HTTP handlers
โ”‚   โ”œโ”€โ”€ models/            # Data models
โ”‚   โ”œโ”€โ”€ http_server/       # Server initilization, endpoints
โ”‚   โ”œโ”€โ”€ middleware/        # Auth checks
โ”‚   โ”œโ”€โ”€ repositories/      # Data access layer
โ”‚   โ”œโ”€โ”€ services/          # Business logic
โ”‚   โ””โ”€โ”€ queue/             # Background jobs
โ”œโ”€โ”€ pkg/                   # Shared packages
โ”œโ”€โ”€ migrations/            # Database migrations
โ”œโ”€โ”€ docs/                  # Swagger documentation
โ””โ”€โ”€ Dockerfile*            # Container configs

โš™๏ธ Configuration

Required Environment Variables

Variable Description Example
JWT_SECRET JWT signing secret your-secret-key-here
MIGRATIONS_PATH Path to migrations ./migrations

Optional Variables (with defaults)

Variable Default Description
LISTEN_ADDR :8080 HTTP server address
REDIS_ADDR :6379 Redis connection
DB_URL postgres://postgres:postgres@db:5432/postgres?sslmode=disable Database URL
MAILGUN_DOMAIN - Email domain (optional)
MAILGUN_API_KEY - Email API key (optional)

๐Ÿ“š API Endpoints

Full Documentation: http://localhost:8080/swagger/index.html

Key Endpoints

Method Endpoint Description
POST /signup Register user
POST /login Authenticate user
GET /profile Get user profile
GET /marketplace/skins List available skins
POST /marketplace/purchase Purchase skin
POST /marketplace/sell List skin for sale
POST /transactions/deposit Deposit funds
POST /transactions/withdraw Withdraw funds

๐Ÿงช Testing

# Run all tests
make test

# Run with coverage
make test-coverage

# Run specific service tests
go test ./internal/services -v

๐Ÿณ Docker Commands

# Build and start
docker-compose up --build

# Start in background
docker-compose up -d

# Stop services
docker-compose down

# View logs
docker-compose logs -f

๐Ÿ”ง Development

# Setup development environment
make dev-setup

# Run locally (requires PostgreSQL & Redis)
make run

# Database migrations
make migrate-up
make migrate-down

# Code generation
make wire
make swagger

๐Ÿ”’ Security Features

  • JWT Authentication with secure token management
  • Password Hashing using bcrypt
  • Input Validation and sanitization
  • SQL Injection Protection with parameterized queries
  • Non-root Containers for security hardening
  • Environment Variables for secure configuration

๐Ÿ“Š Performance Optimizations

  • Multi-stage Docker builds (80% image size reduction)
  • Database connection pooling
  • Redis caching and background job queue
  • Asynchronous processing for emails and PDFs
  • Structured logging with slog
  • Alpine-based images for smaller footprint

๐Ÿ†˜ Troubleshooting

Common Issues

Issue Solution
Email not sending Check Mailgun credentials in .env
Database connection Verify PostgreSQL is running
Build issues Clear Docker cache: docker system prune -a

Getting Help

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

๐Ÿ“ License

This project is licensed under the MIT License.


Built with joy using Go (while being sick) and modern DevOps practices

GitHub LinkedIn

About

A comprehensive marketplace API for buying and selling CS:GO skins, built with Go, featuring user authentication, transaction management, automated invoice generation, and email notifications.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors