Some checks failed
Deploy to Proxmox LXC / deploy (push) Failing after 5s
Go Microservices
Test for actions workflows. Test number 2 Go-based microservices backend with a REST API gateway, gRPC service-to-service communication, JWT auth, and local observability tooling.
Overview
This repo contains:
api-gateway: public HTTP API (/api/v1/*)services/auth-service: authentication and user auth workflowsservices/user-service: user domain serviceservices/post-service: post domain serviceproto: shared protobuf contracts used by gateway and services
Core infra for local development includes PostgreSQL, Redis, Docker Compose, Prometheus, Grafana, and Jaeger.
Project Layout
go-microservices/
├── api-gateway/
├── services/
│ ├── auth-service/
│ ├── user-service/
│ └── post-service/
├── proto/
├── scripts/
├── docker-compose.yml
├── Makefile
└── README.md
Quick Start
Prerequisites:
- Go 1.21+
- Docker + Docker Compose
protocmake
Local startup:
make dev-setup
make db-up
make proto
# run each in separate terminals
make run-auth
make run-user
make run-post
make run-gateway
Docker-first startup:
make docker-build
make docker-up
make docker-logs
API Summary
Base URL: http://localhost:8080/api/v1
Endpoints:
GET /health checkPOST /signupregisterPOST /signinlogin (returnsaccess_token,refresh_token)POST /validatevalidate tokenPOST /userinfoprotected endpoint (Authorization: Bearer <token>)POST /testcreate test entryGET /testslist test entries
Typical auth flow:
POST /signupPOST /signin- Use
access_tokenasBearertoken on protected routes - (Optional)
POST /validate
Service Ports
- API Gateway:
8080 - Auth gRPC:
50051 - User gRPC:
50052 - Post gRPC:
50053 - PostgreSQL:
5432 - Redis:
6379 - Grafana:
3000 - Prometheus:
9090 - Jaeger:
16686
Testing Options
1) Postman
- Import
postman_collection.json - Import
postman_environment.json - Set
base_url=http://localhost:8080 - Run requests in this order: health -> signup -> signin -> validate -> userinfo -> test -> tests
2) Posting (terminal TUI)
./scripts/posting-start.sh
Environment file used by Posting:
~/.config/posting/collections/go_microservices/Go Microservices API.env
3) curl
# Health
curl -X GET http://localhost:8080/api/v1/
# Sign in
curl -X POST http://localhost:8080/api/v1/signin \
-H "Content-Type: application/json" \
-d '{"email":"john@example.com","password":"SecurePassword123!"}'
Common Make Targets
make buildbuild all servicesmake testrun testsmake lintrun lintingmake formatformat codemake protoregenerate protobuf outputmake db-up/make db-downstart/stop DB inframake docker-up/make docker-downstart/stop container stack
Protobuf Regeneration
When proto contracts change, regenerate bindings:
make proto
Direct command example:
protoc --go_out=. --go-grpc_out=. proto/auth.proto
Generated files are expected in service proto directories such as:
services/auth-service/proto/services/user-service/proto/services/post-service/proto/
Troubleshooting
- Port conflicts: stop local stack (
make docker-down) and restart required services - DB errors: run
make db-down && make db-up - Token errors (
401): sign in again and ensureBearerprefix is present - 404/connection errors: verify
base_urland gateway process on:8080
Notes
- API returns JSON for most responses; errors typically use
{ "error": "..." } - JWT can be passed via
Authorizationheader (or cookie where supported) - Keep docs and contract examples in sync when changing endpoint behavior
Description
Languages
Go
75.5%
Makefile
13.4%
Dockerfile
11.1%