Skip to main content

Posts

Showing posts with the label Backend Development

Migrating from OpenAI Assistants API to Responses API: A Step-by-Step Guide

  The abstraction layer provided by the OpenAI Assistants API was a brilliant comprehensive tool for prototyping. It handled thread state, retrieval, and code interpretation automatically. However, with the architectural shift toward the granular   Responses API   (Stateless Inference) and   Conversations API   (State Management), developers must now decouple logic from storage. Relying on the opaque  Runs  and  Threads  objects of the Assistants API often leads to "stuck" states, unpredictable latency due to polling mechanisms, and a lack of control over context window management. This guide provides a rigorous migration path from the black-box Assistants API to a clean, custom architecture using the standard Chat Completions endpoint (acting as the Responses API) and a custom persistence layer (The Conversations API). The Core Problem: Abstraction vs. Control The "Assistants API" is essentially a wrapper around two distinct behaviors: State...

Handling Database Transactions in Hexagonal Architecture Without Leaking Abstractions

  The Blocker: The "Transactional" Annotation Trap You have meticulously designed your Hexagonal Architecture (Ports & Adapters). You have a pristine Domain layer and a segregated Application (Use Case) layer. You have stripped away all frameworks from your core. Then, you write a Use Case that requires atomicity: Deduct inventory. Charge the credit card. Save the order. If any step fails, all must fail. The instinct is to reach for a framework-specific annotation (like Spring’s  @Transactional  or NestJS interceptors) and slap it on the Use Case method. Stop. The moment you import  org.springframework.transaction.annotation.Transactional  (or similar) into your Use Case layer, you have violated the  Dependency Rule . Your inner circle now depends on a framework mechanism living in the outer circle. You are no longer framework-agnostic. If you swap the persistence adapter or the framework, your business logic breaks. The Root Cause: Mixing Business Boun...