The Gateway, the Registry and the Executor: Keeping Groq at the Edge of My Backend
SokoFlow AI Build Log, Week 2 of 6: the LLMClient, the ToolExecutor, and one component that almost became a god object The Week 2 goal said "wire three tools end-to-end." By the end of the week, all three tools executed against PostgreSQL and came back as structured results. I still wouldn't call it end-to-end, and the reason is the most useful thing I learned this week. TL;DR Week 2 built the…
The LLMClient and ToolExecutor components were built to connect three tools end-to-end in SokoFlow, an AI-powered WhatsApp ERP for Kenyan SMEs. The LLMClient acts as a gateway that translates SokoFlow's requests into provider-specific requests and vice versa, keeping provider concepts at the edge of the system. The ToolExecutor handles the execution of the selected tools and runs them against the PostgreSQL database.
Initially, the LLMClient was considered a "god object" as it handled various tasks like tool semantics, existence checks, and retry policies. However, it was later split into three contracts: input contract, output contract, and error contract. The input contract defines what SokoFlow sends to the LLM, the output contract specifies what SokoFlow needs back, and the error contract translates provider-specific failures into application errors.
The ToolRegistry was introduced to provide a centralized location for managing tool definitions, making it easier to extend and manage the tools. By separating concerns and having a clear boundary between the LLMClient and ToolExecutor, the system becomes more maintainable, scalable, and adaptable to future changes, such as switching providers.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.