Quick Reference: For architecture summary, see CLAUDE.md
This document provides detailed architectural information about the VoIPbin monorepo's 34 microservices, their communication patterns, and system design.
bin-api-manager- External REST API gateway with JWT authentication, Swagger UI at/swagger/index.htmlbin-openapi-manager- Centralized OpenAPI 3.0 specification repository, generates Go types used by all services
bin-call-manager- Inbound/outbound call routing, media control (recording, transcription, DTMF, hold, mute)bin-flow-manager- Flow execution engine (IVR workflows), manages action sequences for callsbin-conference-manager- Audio conferencing with recording, transcription, and media streamingbin-transcribe-manager- Audio transcription services (STT)bin-tts-manager- Text-to-Speech integrationbin-registrar-manager- SIP registrar (UDP/TCP/WebRTC)voip-asterisk-proxy- Integration proxy for Asterisk PBX
bin-ai-manager- AI chatbot integrations, summarization, task extractionbin-pipecat-manager- AI voice assistant pipeline managementbin-rag-manager- Retrieval-augmented generation backend (knowledge bases, embeddings)
bin-queue-manager- Call queueing and distribution logicbin-route-manager- Routing policies and rulesbin-transfer-manager- Call transfer logicbin-direct-manager- SIP URI hash routing and direct dial logic
bin-customer-manager- Customer accounts and relationshipsbin-agent-manager- Agent presence, status, permissions, addressesbin-billing-manager- Billing accounts, balance tracking, subscription managementbin-contact-manager- Customer contact records and lookup
bin-campaign-manager- Outbound dialing campaigns with service level trackingbin-outdial-manager- Outbound call dialer enginebin-number-manager- DID and phone number provisioning
bin-message-manager- SMS and messagingbin-email-manager- Email sending and inbox parsingbin-talk-manager- Web chat and live chat integrationbin-conversation-manager- Conversation thread management
bin-common-handler- Shared library (RabbitMQ handlers, data models, utilities)bin-storage-manager- File storage backend (integrates with GCP Cloud Storage)bin-webhook-manager- Webhook sender for customer notificationsbin-hook-manager- Webhook receiversbin-tag-manager- Resource labeling and taggingbin-dbscheme-manager- Database schemas and migrationsbin-sentinel-manager- Monitoring and health checksbin-timeline-manager- Per-resource timeline events
Services communicate using RabbitMQ request/response pattern, not direct HTTP:
// Request format (defined in bin-common-handler/models/sock)
type Request struct {
URI string // e.g., "/v1/calls"
Method string // "GET", "POST", "PUT", "DELETE"
Publisher string // Sending service name
DataType string // "application/json"
Data interface{} // Request payload
}
// Response format
type Response struct {
StatusCode int // HTTP-style status code
DataType string // "application/json"
Data string // JSON response
}- Request queues:
bin-manager.<service-name>.request - Event queues:
bin-manager.<service-name>.event - Delayed exchange:
bin-manager.delay
Use bin-common-handler/pkg/requesthandler which provides typed methods for all services:
import "monorepo/bin-common-handler/pkg/requesthandler"
// Example: Creating a call via call-manager
reqHandler := requesthandler.New(sockHandler)
call, err := reqHandler.CallV1CallCreate(context.Background(), createReq)Use bin-common-handler/pkg/notifyhandler for publishing events:
import "monorepo/bin-common-handler/pkg/notifyhandler"
notifyHandler := notifyhandler.New(sockHandler)
notifyHandler.PublishEvent(event)Most services use Cobra + Viper for configuration (see internal/config packages). Configuration precedence:
- Command-line flags (highest priority)
- Environment variables
- Default values
# Via command-line flags
./service-name \
--database_dsn="user:pass@tcp(host:3306)/db" \
--rabbitmq_address="amqp://guest:guest@localhost:5672" \
--redis_address="localhost:6379" \
--redis_database=1 \
--prometheus_endpoint="/metrics" \
--prometheus_listen_address=":2112"
# Via environment variables
export DATABASE_DSN="user:pass@tcp(host:3306)/db"
export RABBITMQ_ADDRESS="amqp://guest:guest@localhost:5672"
./service-name- Database:
--database_dsn/DATABASE_DSN - RabbitMQ:
--rabbitmq_address/RABBITMQ_ADDRESS - Redis:
--redis_address,--redis_password,--redis_database - Prometheus:
--prometheus_endpoint,--prometheus_listen_address - Queue names:
--rabbit_queue_listen,--rabbit_queue_event
Services follow a consistent structure:
bin-<service-name>/
├── cmd/<service-name>/ # Main entry point
│ ├── main.go # Application initialization
│ └── init.go # Flag/config setup (some services)
├── internal/ # Private packages
│ └── config/ # Configuration management (Cobra/Viper)
├── models/ # Data models and types
├── pkg/ # Business logic packages
│ ├── dbhandler/ # Database and cache operations
│ ├── cachehandler/ # Redis operations
│ ├── listenhandler/ # RabbitMQ request handler
│ ├── subscribehandler/ # Event subscription handler
│ └── <domain>handler/ # Domain-specific handlers
├── gens/ # Generated code (OpenAPI, mocks)
├── openapi/ # OpenAPI specs (for api-manager)
├── k8s/ # Kubernetes manifests
├── vendor/ # Vendored dependencies
├── go.mod # Module definition with replace directives
└── README.md
Each handler follows:
- Interface definition in
main.goor package file - Implementation struct with injected dependencies
- Mock generation via
//go:generate mockgen - Tests in
*_test.gousing table-driven tests
MySQL - Shared database for persistent storage
- Query builder:
github.com/Masterminds/squirrel - Access via
pkg/dbhandlerabstractions in each service
Redis - Distributed cache for:
- Activeflow state (flow-manager)
- Call state and temporary data
- Agent presence information
- Rate limiting and throttling
Always use dbhandler packages - they provide unified interface to both database and cache.
//go:generate mockgen -package packagename -destination ./mock_main.go -source main.go -build_flags=-mod=mod- Tests co-located with source:
*_test.go - Table-driven tests with subtests
- Mocks:
go.uber.org/mock - 34+ test files in flow-manager, similar counts in other services
go test -v ./...
go test -v ./pkg/specifichandler/...Path filtering enables selective service testing:
.circleci/config.yml- Path filter setup.circleci/config_work.yml- Actual build jobs- Only changed services are tested on each commit
github.com/go-sql-driver/mysql- MySQL drivergithub.com/go-redis/redis/v8- Redis clientgithub.com/rabbitmq/amqp091-go- RabbitMQ clientgithub.com/sirupsen/logrus- Structured logginggithub.com/prometheus/client_golang- Prometheus metricsgo.uber.org/mock- Mock generation for testing
github.com/Masterminds/squirrel- SQL query buildergithub.com/spf13/cobra- CLI frameworkgithub.com/spf13/viper- Configuration managementgithub.com/gofrs/uuid- UUID generation
github.com/gin-gonic/gin- HTTP routergithub.com/swaggo/swag- Swagger documentationgithub.com/oapi-codegen/oapi-codegen- OpenAPI code generationgithub.com/golang-jwt/jwt- JWT authentication
cloud.google.com/go/storage- GCP Cloud Storage
- Each service has
k8s/directory with manifests - Prometheus metrics exposed on configured port (default
:2112on/metrics) - Dockerfiles for containerization
- GCP GKE cluster (recommended)
- MySQL database
- Redis cluster
- RabbitMQ cluster
- Asterisk/RTPEngine for media (external to this repo)
- Public domain with TLS