A RESTful API for a Stack Overflow clone built with Go, Gin, and GORM.
- User authentication and authorization
- Question and answer and comment management
- Tag system
- Voting system
- Redis caching
- MySQL database
- Docker and Docker Compose
- Go 1.24.1 or later
- Backend: Go 1.24.1
- Framework: Gin
- ORM: GORM
- Database: MySQL
- Cache: Redis
- Documentation: Swagger
Create a .env file in the root directory with the following variables:
DB_HOST=db
DB_USER=dev
DB_PASSWORD=devpass
DB_NAME=stackoverflow
DB_PORT=3306
JWT_SECRET=your_jwt_secret
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASS=devpass- Build and start the containers:
docker-compose up --build- To stop the containers:
docker-compose down- To view logs:
docker-compose logs -fOnce the application is running, you can access the Swagger documentation at:
http://localhost:8080/swagger/index.html
.
├── controllers/ # Request handlers
├── middleware/ # Custom middleware
├── models/ # Database models
├── routes/ # API routes
├── services/ # Business logic
├── utils/ # Utility functions
├── .env # Environment variables
├── docker-compose.yml
├── Dockerfile
└── main.go # Application entry point
To run the application locally without Docker:
- Install dependencies:
go mod download- Start the application:
go run main.goThis project is licensed under the MIT License.