A Go-based RESTful API for a hospital management system built with Clean Architecture principles.
I started this project as my first serious attempt at building a Go API. Since I’m still new to Go, I may make mistakes along the way. I also used AI to help generate certain parts of the code, but the main goal of this project is to learn the language properly, understand best practices, and eventually create a reusable template for future Go projects.
If you have any suggestions or see areas for improvement, I’d really appreciate the feedback. My background is mainly in TypeScript, so this project is an important step for me to level up my skills in Go
- Go 1.25.4 + Gin Framework
- PostgreSQL 15 + GORM
- JWT Authentication + Bcrypt
- Clean Architecture (Hexagonal)
- Go 1.25.4+
- Docker (for PostgreSQL)
git clone https://github.com/Thanamin/go-api.git
cd go-apigo mod downloadFor Docker Compose (PostgreSQL):
cp docker/docker-compose.env_template docker/.envFor Go API (Project):
cp .env.example .envEdit .env in project root as needed:
DB_HOST=localhost(connect to Docker PostgreSQL from host)PORT=3000(or your preferred port)JWT_SECRETandHASH_SECRET(change to secure keys)
docker compose -f docker/docker-compose.yaml --env-file docker/.env up -d postgresdocker exec -i go-api-postgres psql -U postgres -d go_api_db < migrations/001_initial_schema.sqlThe .env file in project root will be automatically loaded by make start:
make startcurl http://localhost:3000/healthNote: Use the PORT from your .env file
Hot reload (auto-restart on file changes)
go install github.com/cespare/reflex@latest
make devBuild binary
make build
./bin/apiRun tests
go test ./... # All tests
go test -cover ./... # With coverage
go test -v ./... # Verbose| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /health | No | Check API status |
| POST | /staff/create | No | Create new staff member |
| POST | /staff/login | No | Login and get JWT token |
| GET | /patient/search | Yes | Search patients with filters |
Authentication: Use JWT Bearer token from /staff/login
Postman Collection: See document/api-postman/ for detailed API documentation
- hospitals: Hospital information
- staffs: Staff members and authentication
- patients: Patient records
See migrations/001_initial_schema.sql for complete schema.
This project is private and proprietary.
- Author: Thanamin Akkharananwinit
- Email: [email protected]
- GitHub: https://github.com/thanamin
- LinkedIn: https://www.linkedin.com/in/thanamin/