Go backend implementation of the RealWorld API specification
This codebase was created to demonstrate a fully fledged fullstack application built with Go including CRUD operations, authentication, routing, pagination, and more.
We've gone to great lengths to adhere to the Go community styleguides & best practices.
For more information on how to this works with other frontends/backends, head over to the RealWorld repo.
"The mother of all demo apps" β Exemplary fullstack Medium.com clone powered by React, Angular, Node, Django, and many more π
While most "todo" demos provide an excellent cursory glance at a framework's capabilities, they typically don't convey the knowledge & perspective required to actually build real applications with it.
RealWorld solves this by allowing you to choose any frontend (React, Angular, & more) and any backend (Node, Django, & more) and see how the exact same Medium.com clone is built using different tech stacks.
This implementation is built using raeperd/kickstart.go, a minimalistic HTTP server template in Go that provides:
- Small codebase (production-ready starting point)
- Single file server design
- Only standard library dependencies
- Graceful shutdown and health monitoring
- User Management: Registration, authentication, and profile management
- Articles: CRUD operations for articles with slug-based URLs
- Comments: Add, view, and delete comments on articles
- Favorites: Like and unlike articles
- Following: Follow and unfollow other users
- Tags: Discover articles by tags
- Feeds: Global feed and personalized feed for followed users
- RESTful API: Following RealWorld API specification
- JWT Authentication: Secure token-based authentication
- Input Validation: Request validation and error handling
- CORS Support: Cross-origin resource sharing enabled
- OpenAPI Documentation: Interactive API documentation
- Graceful Shutdown: Handles
SIGINTandSIGTERMsignals - Health Monitoring: Service health status with version info
- Access Logging: Comprehensive HTTP request logging
- Panic Recovery: Graceful error handling and recovery
- Debug Endpoints: Built-in profiling and metrics
- Go 1.24 or later
- Make (for build automation)
-
Clone and setup
git clone <your-repo-url> cd realworld.go
-
Build and run
make runServer will start on port 8080
-
Test the API
# Health check curl http://localhost:8080/health # View API documentation curl http://localhost:8080/openapi.yaml
- golangci-lint - Code linting
- air - Hot reload development
# Start development environment with hot reload
docker-compose up
# API server: http://localhost:8080
# Swagger UI: http://localhost:8081All endpoints follow the RealWorld API specification:
-
Authentication
POST /api/users/login- Login userPOST /api/users- Register userGET /api/user- Get current userPUT /api/user- Update user
-
Profiles
GET /api/profiles/:username- Get profilePOST /api/profiles/:username/follow- Follow userDELETE /api/profiles/:username/follow- Unfollow user
-
Articles
GET /api/articles- List articles (with filters)GET /api/articles/feed- Get user feedPOST /api/articles- Create articleGET /api/articles/:slug- Get articlePUT /api/articles/:slug- Update articleDELETE /api/articles/:slug- Delete article
-
Comments
GET /api/articles/:slug/comments- Get commentsPOST /api/articles/:slug/comments- Add commentDELETE /api/articles/:slug/comments/:id- Delete comment
-
Favorites & Tags
POST /api/articles/:slug/favorite- Favorite articleDELETE /api/articles/:slug/favorite- Unfavorite articleGET /api/tags- Get tags
GET /health- Service health with version infoGET /openapi.yaml- OpenAPI specificationGET /debug/pprof/*- Profiling informationGET /debug/vars- Runtime metrics
# Run all tests
make test
# Run specific test
go test -v -run TestHealth
# Run tests with coverage
go test -v -cover ./...# Build Docker image
make docker
# Run containerized
docker run -p 8080:8080 realworld.goVERSION- Application version (default: "dev")PORT- Server port (default: "8080")
.
βββ main.go # Main server implementation
βββ main_test.go # Integration tests
βββ api/
β βββ openapi.yaml # OpenAPI specification
βββ docker-compose.yaml # Development environment
βββ Dockerfile # Container build
βββ Makefile # Build automation
βββ README.md # This file
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes following Go best practices
- Add tests for new functionality
- Ensure tests pass:
make test - Run linter:
make lint - Submit a pull request
- RealWorld Project - Main RealWorld repository
- RealWorld Demo - Live demo application
- RealWorld Docs - API documentation
- kickstart.go - Original template used