This directory contains the Go-based microservices for the PyAirtable platform, implementing a modern 22-service architecture.
- API Gateway (Port 8080): Routes all external traffic, handles authentication, rate limiting
- Auth Service (Port 8001): JWT authentication, user registration, token management
- User Service (Port 8002): User profile management, CRUD operations
- Airtable Gateway (Port 8003): Proxy for Airtable API with caching and rate limiting
- Tenant Service: Multi-tenancy management
- Workspace Service: Workspace organization
- Permission Service: RBAC and access control
- Workflow Engine: Automation and task scheduling
- Analytics Service: Metrics and reporting
- File Service: File upload and processing
- Notification Service: Email/SMS/Push notifications
- Webhook Service: External integrations
- AI Service: LLM integration and AI features
- Search Service: Full-text search with Elasticsearch
- Export Service: Data export in various formats
- Import Service: Bulk data import
- Sync Service: Real-time data synchronization
- Audit Service: Activity logging and compliance
- Billing Service: Subscription and payment processing
- Admin Service: Platform administration
- Go 1.23+
- Docker & Docker Compose
- PostgreSQL 16
- Redis 7
- Make
-
Set up environment variables
cp .env.example .env # Edit .env with your configuration -
Start infrastructure
docker-compose -f docker-compose.phase1.yml up postgres redis
-
Run a service locally
cd auth-service go run cmd/auth-service/main.go -
Run all Phase 1 services
docker-compose -f docker-compose.phase1.yml up
-
Test the services
./test-phase1.sh
Each service follows a standard structure:
service-name/
├── cmd/
│ └── service-name/
│ └── main.go # Entry point
├── internal/
│ ├── config/ # Configuration
│ ├── handlers/ # HTTP handlers
│ ├── models/ # Data models
│ ├── repository/ # Data access layer
│ ├── services/ # Business logic
│ └── middleware/ # HTTP middleware
├── pkg/ # Shared packages
├── Dockerfile
├── go.mod
├── go.sum
└── README.md
cd service-name
go build -o bin/service-name cmd/service-name/main.gogo test ./...go mod tidygo generate ./...POST /api/v1/auth/register- Register new userPOST /api/v1/auth/login- User loginPOST /api/v1/auth/refresh- Refresh access tokenPOST /api/v1/auth/logout- User logout
GET /api/v1/users/me- Get current userPUT /api/v1/users/me- Update current userGET /api/v1/users/:id- Get user by IDPUT /api/v1/users/:id- Update userDELETE /api/v1/users/:id- Delete userGET /api/v1/users- List users
GET /api/v1/airtable/bases- List basesGET /api/v1/airtable/bases/:baseId- Get baseGET /api/v1/airtable/bases/:baseId/tables- List tablesGET /api/v1/airtable/bases/:baseId/tables/:tableId- Get tableGET /api/v1/airtable/bases/:baseId/tables/:tableId/records- List recordsPOST /api/v1/airtable/bases/:baseId/tables/:tableId/records- Create recordGET /api/v1/airtable/bases/:baseId/tables/:tableId/records/:recordId- Get recordPATCH /api/v1/airtable/bases/:baseId/tables/:tableId/records/:recordId- Update recordDELETE /api/v1/airtable/bases/:baseId/tables/:tableId/records/:recordId- Delete record
- JWT authentication with access/refresh tokens
- Rate limiting per IP address
- CORS configuration
- Request ID tracking
- Secure password hashing with bcrypt
- SQL injection prevention
- Input validation
Each service has its own database following the database-per-service pattern:
- pyairtable_auth: Users, sessions, tokens
- pyairtable_users: User profiles, preferences
- pyairtable_tenants: Organizations, subscriptions
- pyairtable_workspaces: Workspaces, projects
- pyairtable_permissions: Roles, permissions
- pyairtable_workflows: Automation rules, schedules
- pyairtable_analytics: Metrics, reports
Each service includes a multi-stage Dockerfile for optimal image size:
# Build stage
FROM golang:1.23-alpine AS builder
# ... build steps ...
# Final stage
FROM alpine:latest
# ... runtime configuration ...Services expose metrics for Prometheus:
- Request count
- Request duration
- Error rate
- Custom business metrics
Health endpoints:
/health- Basic health check/ready- Readiness probe/metrics- Prometheus metrics
- Follow the existing code structure
- Write tests for new features
- Update documentation
- Use conventional commits
- Run linters before committing
Copyright (c) 2024 PyAirtable. All rights reserved.