A toy project for testing modern Go technologies including ConnectRPC, Testcontainers, and MinIO object storage.
- ConnectRPC: Type-safe RPC communication with HTTP/JSON support
- PostgreSQL: Database with SQLC for type-safe queries
- OAuth2 Authentication: GitHub OAuth integration
- JWT Tokens: Secure authentication with JWT
- MinIO Object Storage: File upload and management
- Testcontainers: Integration testing with real databases
- Microservices Architecture: Versioned service structure
├── cmd/ # CLI commands (Cobra)
├── db/ # Database schema and queries
├── gen/ # Generated code (SQLC)
├── pkg/ # Shared packages
├── service/ # Microservices
│ ├── auth/v1/ # Authentication service
│ ├── user/v1/ # User management (stub)
│ ├── post/v1/ # Blog posts (stub)
│ └── object/v1/ # File storage (stub)
└── server/ # HTTP server
- Language: Go 1.21+
- RPC Framework: ConnectRPC
- Database: PostgreSQL with SQLC
- Authentication: OAuth2 (GitHub) + JWT
- Object Storage: MinIO
- Testing: Testcontainers
- CLI: Cobra
- Package Management: pkgx
- Go 1.21+
- PostgreSQL
- MinIO (optional, for object storage)
# GitHub OAuth
GITHUB_OAUTH2_CLIENT_ID=your_client_id
GITHUB_OAUTH2_CLIENT_SECRET=your_client_secret
GITHUB_OAUTH2_REDIRECT_URL=http://your-application-url
# JWT
JWT_SIGNING_SECRET=your_secret_key# Clone the repository
git clone https://github.com/gaesemo/tech-blog-server.git
cd tech-blog-server
# Generate database code
./script/generate.sh
# Run the server
go run . serve# Generate type-safe database code
./script/generate.sh
# Run with custom port and debug logging
go run . serve --port 9000 --log-level debug
# Build the project
go build -o gsm .
# Run tests
go test ./...The server provides ConnectRPC services:
-
Auth Service (
/service.auth.v1.AuthService/)GetAuthURL- Get OAuth authorization URLLogin- Exchange auth code for JWT tokenLogout- Invalidate session
-
User Service (
/service.user.v1.UserService/) - Coming Soon -
Post Service (
/service.post.v1.PostService/) - Coming Soon -
Object Service (
/service.object.v1.ObjectService/) - Coming Soon
This project uses Testcontainers for integration testing with real PostgreSQL instances:
# Run all tests
go test ./...
# Run specific test
go test ./server -vThe project uses PostgreSQL with the following core entities:
- Users: OAuth-authenticated users with soft delete support
- Follows: Social graph relationships (planned)
- Subscriptions: Paid subscription model (planned)
This is a toy project for learning purposes. Feel free to explore, fork, and experiment!
This project is licensed under the MIT License - see the LICENSE file for details.
- ConnectRPC for the excellent RPC framework
- SQLC for type-safe SQL
- Testcontainers for integration testing
- MinIO for object storage