Skip to content

Files

122 lines (87 loc) · 2.2 KB

README.md

File metadata and controls

122 lines (87 loc) · 2.2 KB

Social-Go

A simple social media backend application built with Go.

Description

This project implements a basic social media backend with user management, posts, and interactions.

Features

  • User management (registration, authentication)
  • Post creation and management
  • PostgreSQL database
  • Docker containerization
  • Database migrations using Goose

Prerequisites

  • Go 1.23 or later
  • Docker and Docker Compose
  • Goose for database migrations

Setup

  1. Clone the repository
git clone https://github.com/batugkocak/social-go.git
cd social-go
  1. Environment Setup

Create a .env file in the root directory:

ENV = development
ADDR=:8080
DB_ADDR=postgres://admin:adminPassword@localhost/social?sslmode=disable
DB_MAX_OPEN_CONNS=30
DB_MAX_IDLE_CONNS=30
DB_MAX_IDLE_TIME=15min
  1. Start Docker Services
docker-compose up -d

This will start the PostgreSQL database on port 5432.

  1. Database Migrations

Install Goose:

go install github.com/pressly/goose/v3/cmd/goose@latest

Run migrations:

# Set your database connection string
export GOOSE_DRIVER=postgres
export GOOSE_DBSTRING="postgres://admin:adminPassword@localhost/social?sslmode=disable"

# Run migrations
goose up

To create a new migration:

goose create name_of_your_migration sql
  1. Seed the database (optional)
make seed
  1. Run the Application
# Run directly
go run ./cmd/api

# Or use air for hot reload (if installed)
air

API Endpoints

  • GET /v1/health - Health check endpoint
  • More endpoints documentation coming soon...

Development

The project uses:

  • Chi router for HTTP routing
  • PostgreSQL for data storage
  • Docker for containerization
  • Goose for database migrations

Project Structure

.
├── cmd/
│   ├── api/          # Main application
│   └── migrate/      # Database migrations
├── internal/
│   ├── db/          # Database connection
│   ├── env/         # Environment configuration
│   ├── scripts/     # Database scripts
│   └── store/       # Data access layer
└── docker-compose.yml

License

MIT License