Training. Learning exercise in Go microservices (hexagonal layout, gRPC, Fiber gateway). Not production-hardened: gaps in tests, key management, and ops defaults remain.
Module: github.com/flexer2006/notes-microservices
Services: auth, notes, HTTP gateway.
- Go
- PostgreSQL (DB per service: auth / notes)
- Redis (gateway cache)
- Fiber v3 + Nginx
- gRPC + protobuf
- JWT HS256 (separate access/refresh secrets) + bcrypt
- golang-migrate
- Docker Compose
From this repository root:
cp .env.example deploy/.env
docker compose -f deploy/docker-compose.yml up -d --buildHTTP API: http://localhost:80 (Nginx → gateway).
task proto:gen # or: bash scripts/gen_proto.sh
go run ./cmd/auth &
go run ./cmd/notes &
go run ./cmd/gatewayRequires local Postgres/Redis (or Compose infra) and env from .env.example.
POST /api/v1/auth/registerPOST /api/v1/auth/loginPOST /api/v1/auth/refreshPOST /api/v1/auth/logoutGET /api/v1/user/profile
POST /api/v1/notesGET /api/v1/notes/{note_id}GET /api/v1/notes?limit=10&offset=0PATCH /api/v1/notes/{note_id}PUT /api/v1/notes/{note_id}DELETE /api/v1/notes/{note_id}
go test ./...
go vet ./...
golangci-lint run ./...Paths relative to this repository root:
cmd/auth|notes|gateway # process entrypoints
internal/bootstrap # composition root
internal/app # use cases / BFF
internal/ports # interfaces
internal/domain # entities / errors
internal/adapters/ # grpc, http, postgres, redis, jwt, bcrypt
internal/{config,fault,logger,authctx}
api/**/*.proto → gen/ # task proto:gen
migrations/{auth,notes}/
deploy/ # compose, Dockerfile, nginx
scripts/gen_proto.sh
.env.example
flowchart LR
C([Client]) --> N[Nginx :80]
N --> G["gateway<br/>cmd/gateway"]
G -->|gRPC| A["auth<br/>cmd/auth :50052"]
G -->|gRPC| S["notes<br/>cmd/notes :50053"]
G --> R[(Redis)]
A --> PA[(Postgres auth)]
S --> PN[(Postgres notes)]
A -.->|access JWT| S