A complete Go-based microservices platform for the Guardian security and community management system.
Guardian Go is built entirely in Go with a modern microservices architecture. All services are containerized and orchestrated with Docker Compose.
| Service | Port | Purpose | Tech Stack |
|---|---|---|---|
| Guardian.ApiGo | 3000 | REST API Backend | Go, Gin, PostgreSQL |
| Guardian.WebUserGo | 3001 | Customer Web Portal | Go, HTML/Template, PostgreSQL |
| Guardian.GuardsGo | 3002 | Guard Management API | Go, Gin, PostgreSQL |
| Guardian.PartnersGo | 3003 | Partner Management API | Go, Gin, PostgreSQL |
| Guardian.WebAdminGo | 3004 | Admin Dashboard | Go, HTML/Template, PostgreSQL |
| Guardian.WebPartnerGo | 3005 | Partner Portal | Go, HTML/Template, PostgreSQL |
- Go 1.21+
- Docker & Docker Compose
- PostgreSQL 16 (for local development)
- Make (optional)
-
Clone and setup
cd services -
Start PostgreSQL
docker-compose up -d db
-
Build all services
# Using VS Code task Run task: build-all-go # Or manually cd Guardian.ApiGo && go build -o guardian-api . cd ../Guardian.WebUserGo && go build -o guardian-web-user-go . # ... repeat for other services
-
Run services
# Individual service in VS Code Debug: Guardian.ApiGo # Or all together Run task: docker-up
# Build and start all services
docker-compose up --build
# Stop all services
docker-compose downservices/
βββ Guardian.ApiGo/ # Core REST API
β βββ main.go
β βββ models.go
β βββ middleware.go
β βββ api_*.go # API handlers
β βββ go.mod
β βββ Dockerfile
βββ Guardian.WebUserGo/ # Customer portal
β βββ main.go
β βββ middleware.go
β βββ pages_*.go # Page handlers
β βββ templates/ # HTML templates
β βββ static/ # CSS, JS, images
β βββ Dockerfile
βββ Guardian.GuardsGo/ # Guard management
βββ Guardian.PartnersGo/ # Partner management
βββ Guardian.WebAdminGo/ # Admin dashboard
βββ Guardian.WebPartnerGo/ # Partner portal
build-api-go- Build Guardian.ApiGobuild-web-user-go- Build Guardian.WebUserGobuild-guards-go- Build Guardian.GuardsGobuild-partners-go- Build Guardian.PartnersGobuild-web-admin-go- Build Guardian.WebAdminGobuild-web-partner-go- Build Guardian.WebPartnerGobuild-all-go- Build all services
test-api-go- Test Guardian.ApiGotest-all-go- Test all services
docker-build- Build Docker imagesdocker-up- Start all servicesdocker-down- Stop all services
All services use JWT (JSON Web Tokens) for authentication:
- JWT Secret: Set via
JWT_SECRETenvironment variable - Token Expiry: 24 hours
- Protected Routes: Require valid JWT in Authorization header
# Database
DB_USER=postgres
DB_PASSWORD=password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=guardian_go
# API
JWT_SECRET=your-secret-key-here
PORT=3000
# Optional
DEBUG=true
LOG_LEVEL=infoEach service provides comprehensive API endpoints:
/api/auth/register- User registration/api/auth/login- User authentication/api/users/*- User management/api/services/*- Service management/api/bookings/*- Booking management
/api/auth/*- Guard authentication/api/profile/*- Guard profile/api/assignments/*- Job assignments
/api/auth/*- Partner authentication/api/profile/*- Partner profile/api/services/*- Service management/api/availability/*- Availability management
- Web portals serve server-rendered HTML with Tailwind CSS
- RESTful API integration via fetch/AJAX
- Protected pages require authentication
PostgreSQL 16 with schema:
Main Tables:
users- System users (customers, guards, partners)guards- Guard profiles and certificationspartners- Partner businesses and servicesservices- Available servicesbookings- Service bookingsreviews- Service reviews and ratingsavailability- Guard/Partner availability schedules
# Test specific service
go test ./... -v -run <test_name>
# Run all service tests
task test-all-gogin-gonic/ginv1.11.0 - Web frameworkjackc/pgxv5.8.0 - PostgreSQL drivergolang-jwt/jwtv5.3.1 - JWT authentication
joho/godotenvv1.5.1 - Environment configurationgolang.org/x/cryptov0.41.0 - Password hashing
- Update
JWT_SECRETenvironment variable - Configure production database credentials
- Set
DEBUG=false - Review CORS settings
- Configure nginx reverse proxy
- Set up SSL/TLS certificates
- Enable database backups
- Configure monitoring and logging
# Update environment in docker-compose.yml
services:
db:
environment:
POSTGRES_PASSWORD: <strong-password>
api:
environment:
JWT_SECRET: <production-secret>
DB_PASSWORD: <strong-password>- Create handler function in appropriate
api_*.goorpages_*.go - Register route in
main.go - Add tests in
*_test.go - Build and test:
go buildand run locally
- Create new directory:
Guardian.NewServiceGo/ - Copy structure from existing service
- Update
docker-compose.yml - Update
.vscode/launch.jsonandtasks.json - Update this README
Services log to stdout (visible in docker-compose output):
# View logs
docker-compose logs -f api
# Specific service
docker-compose logs guardian-api- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or suggestions:
- Check existing documentation in
/docs - Open an issue on GitHub
- Contact the development team
Last Updated: 2024 Go Version: 1.21+ Status: Production Ready