Emre Şahin

Архитектонске студије случаја

BigiBuddy

Дистрибуирана гласовна AI платформа. Шифрована повезаност уређаја у реалном времену преко WebSockets, аудио pipeline ка AI и LLM сервисима и event-driven размена порука уз RabbitMQ и Redis.

Улога
Backend девелопер → архитекта решења
Период
2023 – 2026
Технологије
.NET, WebSocket, gRPC, Python AI, RabbitMQ, Redis, OpenTelemetry

Simplified and anonymised: no source code, customer data or confidential architecture details.

Overview & business problem

BigiBuddy is a voice AI companion: a small connected device that listens, understands and talks back. Behind every conversation sits a backend that has to keep devices connected, route audio to speech and language services, return an answer quickly enough to feel natural, and still run an ordinary consumer business around it: accounts, subscriptions, orders, payments and content.

The hard part is that these two worlds have very different shapes. Device traffic is long-lived, stateful and latency-sensitive. Commerce and account traffic is classic request and response. The platform had to serve both without one degrading the other.

My role & requirements

I joined the BigiBuddy backend team at Fortech in late 2023 and built backend services for about two years: device connectivity, authentication, subscriptions and the integration with the AI audio services. In late 2025 I moved into a Solutions Architect role and have since guided the backend's architecture, including a gradual migration of the business layer.

The requirements we worked against were consistent throughout:

  • Devices must stay reachable in real time, even when the API runs on several instances.
  • Voice requests must not block on slow work such as transcoding or content generation.
  • AI providers change. Swapping a speech or language provider must not ripple through the product code.
  • Account security has to meet modern expectations: MFA, passkeys and social sign-in.
  • The team must be able to keep shipping features while the architecture underneath improves.

Architecture & design decisions

The diagram on this page is simplified and is not the real production topology.

At its core, BigiBuddy is a .NET backend with Clean Architecture layering (presentation, business, infrastructure, persistence, core) and PostgreSQL as the system of record. A gateway in front handles routing and edge policies. Around that core sit four supporting pieces.

Persistent device connections, routed through Redis. Devices hold a WebSocket connection to whichever API instance accepted them. When another instance needs to reach a device, for example to deliver a reply from a background job, it publishes to a Redis channel, and the instance holding the socket writes it to the device. This kept the API stateless for the load balancer without an extra connection service.

AI audio work behind a gRPC contract. Speech-to-text, text-to-speech, audio processing and language model calls live in separate Python services behind one gRPC contract. I preferred gRPC over REST because the payloads are binary audio, the calls are internal, and a typed contract turns a provider change into a new operation rather than a renegotiated JSON shape. Product code asks for "transcribe this", not "call vendor X".

Asynchronous work through RabbitMQ and Hangfire. Anything that need not finish inside the request goes onto a queue or into a scheduled job: logging, content processing, notifications and subscription renewals. RabbitMQ carries events; Hangfire, backed by Redis, runs recurring and delayed jobs.

Observability from the first message. OpenTelemetry traces and metrics go to Prometheus and a tracing backend, so a slow voice turn can be followed from the device to the AI call and back.

From managers to domains. The original business layer was organised as interface-and-manager pairs per feature. Cross-cutting rules were scattered and large classes kept growing. As architect, I set a direction rather than a rewrite: new code goes into domain modules (authentication, devices, users, subscriptions, payments, content, AI), each with its own services, handlers, providers and strategies. Legacy managers move when they are touched for a real reason. Authentication moved early, which let us add TOTP, passkeys and social providers as strategies instead of conditionals.

Trade-offs

Redis fan-out instead of a dedicated connection gateway. A separate device gateway would scale and isolate more cleanly, but it is another service to deploy, secure and debug. Redis was already in the stack. The cost is best-effort delivery, so anything that must arrive is also persisted and retried.

Incremental migration instead of a rewrite. Two styles coexist for a while, which needs clear rules in code review. In return, feature work never stopped, and each migrated domain was tested against real behaviour.

One gRPC contract for all audio work. Easy to discover, but it grows wide. We accepted that for simpler deployment.

A modular backend before microservices. We kept the core as one deployable with clear internal boundaries. That kept operations manageable for a small team; the domain modules are the seams if a split ever becomes worth it.

Security & scalability

Authentication supports password, TOTP, passkeys (FIDO2) and social sign-in, with separate strategies for end users and administrators. Admin endpoints use permission-based authorization at module and action level. Secrets are read from a managed secret store at runtime, and rate limiting sits at the edge and in middleware.

For scale, API instances are stateless, device sessions are located through Redis, slow work moves to queues, and the AI services scale independently behind gRPC.

Results & lessons learned

The platform now separates real-time device traffic, AI audio processing and business logic into parts that evolve independently. Adding a speech or language provider is a contained change. The domain structure is the default for new work, and traces connect a device message to the downstream AI call.

The main lesson is that architecture in a live product is mostly about direction and guardrails. A clear rule for where new code goes did more than any diagram.

What I'd do differently today

  • Introduce the domain structure much earlier, before the legacy layer grew large enough to need a migration.
  • Define delivery guarantees for device messages explicitly from day one, rather than relying on best-effort pub/sub and adding persistence later.
  • Split the AI contract by capability (speech, language, audio processing) from the start, so each can version and scale on its own.
  • Add architecture tests that enforce layer and domain boundaries in CI, instead of relying on code review alone.