Skip to content

A production-ready Go backend service implementing a social media platform with features like post management, user authentication, and commenting system. Built using modern Go practices and following clean architecture principles.

Notifications You must be signed in to change notification settings

batugkocak/Social

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A production-ready Go backend service implementing a social media platform with features like post management, user authentication, and commenting system. Built using modern Go practices and following clean architecture principles.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published