A simple social media backend application built with Go.
This project implements a basic social media backend with user management, posts, and interactions.
- User management (registration, authentication)
- Post creation and management
- PostgreSQL database
- Docker containerization
- Database migrations using Goose
- Go 1.23 or later
- Docker and Docker Compose
- Goose for database migrations
- Clone the repository
git clone https://github.com/batugkocak/social-go.git
cd social-go- 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- Start Docker Services
docker-compose up -dThis will start the PostgreSQL database on port 5432.
- Database Migrations
Install Goose:
go install github.com/pressly/goose/v3/cmd/goose@latestRun migrations:
# Set your database connection string
export GOOSE_DRIVER=postgres
export GOOSE_DBSTRING="postgres://admin:adminPassword@localhost/social?sslmode=disable"
# Run migrations
goose upTo create a new migration:
goose create name_of_your_migration sql- Seed the database (optional)
make seed- Run the Application
# Run directly
go run ./cmd/api
# Or use air for hot reload (if installed)
airGET /v1/health- Health check endpoint- More endpoints documentation coming soon...
The project uses:
- Chi router for HTTP routing
- PostgreSQL for data storage
- Docker for containerization
- Goose for database migrations
.
├── cmd/
│ ├── api/ # Main application
│ └── migrate/ # Database migrations
├── internal/
│ ├── db/ # Database connection
│ ├── env/ # Environment configuration
│ ├── scripts/ # Database scripts
│ └── store/ # Data access layer
└── docker-compose.yml