Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using_Hono_in__B2B_SaaS_Application.pdf

sugar-cat
June 21, 2024
330

 Using_Hono_in__B2B_SaaS_Application.pdf

sugar-cat

June 21, 2024
Tweet

More Decks by sugar-cat

Transcript

  1. What is Hono • Fast, lightweight, built on Web Standards

    ◦ Runtime Compatibility: Node, Deno, Bun, Workers Key Features: • Built-in Middleware: A wide range of middleware is included by default, ensuring smooth development. • Simple and Intuitive API: Designed with a clear and easy-to-understand API, allowing for rapid development.
  2. AI

  3. Using Streaming SSE for Real-time Response • Expressing that responses

    are gradually returned in an interactive AI UI.
  4. Example: SSE with Hono Helper + GPT streamSSE: A helper

    to handle responses as SSE (Server-Sent Events)
  5. Example: SSE with Hono Helper + GPT Push to the

    client using data: { "hoge": "fuga!" } format.
  6. Example: SSE with Hono Helper + GPT Close the stream

    at the end of processing or on interruption.
  7. RAG

  8. Uploading Documents for Search Now, one important point in performing

    RAG (Retrieval-Augmented Generation) is that documents need to be registered in the Vector Store in advance.
  9. Uploading Documents for Search The user uploads a file in

    some way, which is then embedded and stored in the vector store.
  10. AI Worker as a Bridge Model Multi-tenant • Single Instance

    with Multiple Schemas • Switching Based on Tenant ID
  11. AI Worker as a Bridge Model Multi-tenant • Single Instance

    with Multiple Schemas • Switching Based on Tenant ID TenantID
  12. Extracting Tenant ID from Access Token Set tenantID in the

    context and propagate it to subsequent processes.
  13. Security:Validation at DB and Response Levels Our company adopts Clean

    Architecture and DDD, resulting in separated layers. Request Response Handler Usecase Repository
  14. Security:Validation at DB and Response Levels It is necessary to

    properly validate each layer to prevent unnecessary fields from leaking. Request Response Handler Usecase Repository
  15. Security:Validation at DB and Response Levels Request Response Handler Usecase

    Repository Pass the response through Zod's parse as a DTO to avoid unnecessary fields and potential incidents.
  16. Conclusion • In AI Worker, we use Hono's features for

    various aspects such as RAG, B2B tenant management, and security measures. For those who want to learn more about Hono: