Skip to main content

System Architecture

Rapida is a Go-based microservices platform (module: github.com/rapidaai, Go 1.25). Services communicate over gRPC internally and expose REST and gRPC-web APIs via a shared Nginx gateway on port 8080. A single TCP port per service multiplexes HTTP/2 (gRPC), grpc-web, and HTTP/1.1 using cmux.

Service Responsibilities

ServicePortLanguageResponsibility
web-api9001GoAuth, organizations, projects, credential vault
assistant-api9007GoVoice orchestration, STT/TTS pipeline, telephony
integration-api9004GoLLM/STT/TTS provider integrations, OAuth
endpoint-api9005GoWebhook management, event routing, retry
document-api (optional)9010PythonDocument processing, embeddings, RAG (FastAPI) — knowledge base only
ui3000React/TSFrontend dashboard
nginx8080Reverse proxy, WebSocket upgrade, SSL/TLS
document-api and opensearch are optional. They are only needed for knowledge base / RAG features. Voice assistants (STT/LLM/TTS) work fully without them.

Nginx Routing

The Nginx gateway at port 8080 routes requests based on the gRPC service path prefix:
Path PatternUpstreamProtocol
/talk_api.TalkService/AssistantTalkassistant-api:9007WebSocket upgrade
/talk_apiassistant-api:9007gRPC-web
/tool_api, /web_api, /vault_api, /workflow_api, /assistant_api, /knowledge_api, /connect_api, /lead_apiweb-api:9001gRPC-web
/rapida-data/assets/workflow/Static filesHTTP
/web-api:9001HTTP proxy
Real-time audio connections use the WebSocket upgrade path. The browser SDK connects to ws://hostname:8080/talk_api.TalkService/AssistantTalk for bidirectional audio streaming.

Data Layer

PostgreSQL Databases

PostgreSQL 15 is the primary relational store. Each service owns a dedicated database. The init.sql initializes all required databases on first container start.
DatabaseOwnersPurpose
web_dbweb-apiUsers, organizations, projects, API keys, vault
assistant_dbassistant-api, document-apiAssistants, conversations, messages, embeddings
integration_dbintegration-apiIntegrations, provider credentials, OAuth tokens
endpoint_dbendpoint-apiWebhooks, endpoints, delivery logs
PostgreSQL :5432
├── web_db        ← web-api
├── assistant_db  ← assistant-api + document-api
├── integration_db ← integration-api
└── endpoint_db   ← endpoint-api
The web_db is defined as the default database in POSTGRES_DB in docker-compose and created automatically by the PostgreSQL image. The remaining three databases are created by docker/postgres/init.sql.

Redis Databases

Redis 7 serves as the in-memory cache, session store, and job broker.
DBPurpose
0General application cache (GORM second-level cache)
1Session / auth token cache
2Celery job broker (document-api background jobs)

OpenSearch Indices (Optional — Knowledge Base Only)

OpenSearch 2.11.1 handles full-text search and vector similarity search. It is only required when running with the knowledge base profile (make up-all-with-knowledge).
IndexProducerPurpose
assistant-conversationsassistant-apiSearchable conversation transcripts
conversation-metricsassistant-apiCall latency and quality metrics
documents-*document-apiKnowledge base chunks and embeddings
logs-*assistant-apiStructured application logs

Data Flows

1. User Authentication

2. Voice Conversation

3. Inbound Phone Call (Twilio / Vonage)

4. SIP / Asterisk Connection

5. Document Upload and RAG Indexing


Communication Patterns

Synchronous

PatternUsed ForImplementation
REST/HTTPExternal-facing API calls, health checksGin framework
gRPCInter-service calls (typed, schema-enforced)gRPC + protobuf
gRPC-webBrowser → backend (gRPC over HTTP/1.1)improbable-eng grpc-web
WebSocketReal-time audio streaming (assistant-api)gorilla/websocket

Asynchronous

PatternUsed ForImplementation
Redis Pub/SubReal-time session updates, notificationsgo-redis
Celery tasksDocument processing, embedding generationRedis broker
WebhooksExternal event delivery with retryendpoint-api

Port Reference

ServicePortProtocolNotes
nginx8080HTTP / WebSocketExternal entry point
ui3000HTTPReact development server / production build
web-api9001HTTP + gRPC + gRPC-webcmux multiplexed
assistant-api9007HTTP + gRPC + WebSocketcmux multiplexed; real-time audio
assistant-api4573TCP (AudioSocket)Asterisk AudioSocket integration
integration-api9004HTTP + gRPCcmux multiplexed
endpoint-api9005HTTP + gRPCcmux multiplexed
document-api9010HTTP (FastAPI)ASGI / uvicorn
PostgreSQL5432TCPInternal only (not exposed publicly)
Redis6379TCPInternal only
OpenSearch9200HTTPInternal; 9600 for metrics

Scaling

All application services are stateless and scale horizontally behind the Nginx load balancer.
LayerScaling Strategy
ApplicationHorizontal (stateless pods/containers)
PostgreSQLVertical + read replicas
RedisVertical or cluster mode
OpenSearchHorizontal (node count + shard count)

Next Steps