Skip to content

abuenosdiaz/embedded-chat-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Embedded Chat Platform

New architecture for the embedded chat widget: client -> litellm -> langflow.

This is a separate, leaner repo from PREAA — it only runs the services this architecture needs, instead of PREAA's full stack (LibreChat, RagFlow, n8n, Open WebUI, etc).

Ownership

  • Ariel — embedded chat widget experience (packages/admin-v2's widget config + the deep-chat-based embed script)
  • Anurag — backend services (LiteLLM, LangFlow, Langfuse, Keycloak)

Structure

deploy/                  # docker-compose stack: litellm, langflow, langfuse, keycloak
  docker-compose.yml
  config/                # env samples + litellm.yaml (copy .sample -> real file, fill in secrets)
  postgres-init/         # creates the langflow/litellm databases on first boot
packages/
  admin-v2/               # widget config dashboard (Next.js + Prisma + NextAuth/Keycloak)
    public/widget-loader.js  # embeddable widget script, renders via deep-chat
    prisma/schema.prisma     # WidgetConfig model (bot name, theme, LangFlow flow id, ...)

packages/admin-v2 manages per-site widget configs (bot name, welcome message, theme colors, which LangFlow flow + system prompt it talks to, streaming on/off) backed by Postgres via Prisma, and proxies chat requests through to LangFlow. It also has read-only pages for LangFlow flows, LiteLLM models/keys, and Langfuse projects.

Getting started

  1. Copy the env samples and fill in real secrets:

    cd deploy/config
    for f in .env.*.sample; do cp "$f" "${f%.sample}"; done

    At minimum, set real passwords/keys in .env.psql, .env.redis, .env.minio, .env.clickhouse, .env.litellm, .env.langfuse, .env.keycloak, and point .env.litellm / .env.langflow's DATABASE_URL passwords at the same one you set in .env.psql.

  2. Start the backend stack:

    cd deploy
    docker compose up -d
  3. Run the dashboard:

    cd packages/admin-v2
    cp .env.sample .env.local   # fill in LangFlow/LiteLLM/Langfuse + Keycloak client values
    npm install
    npx prisma migrate deploy   # creates the WidgetConfig table
    npm run dev                 # runs on :3019

    Sign-in is gated by Keycloak (src/proxy.ts — Next.js 16 renamed middleware.ts to proxy.ts). The widget config GET endpoint (/api/widgets/[id]) and the chat proxy (/api/widgets/[id]/chat) are intentionally left public since third-party pages call them directly, unauthenticated, via widget-loader.js.

  4. Try the embed: open http://localhost:3019/test-embed.html after creating a widget at /widgets/new.

Known follow-ups

  • deploy/config/litellm.yaml does not yet wire LiteLLM's custom_provider_map to LangFlow. PREAA does this via packages/litellm/custom/langflow_handler.py, but that handler depends on a separate "helper backend" service for model -> flow mapping that isn't part of this stack. Anurag to decide how routing should work here before porting that handler over.
  • Keycloak runs in start-dev mode with an ephemeral dev database — fine for getting started, not for anything beyond local dev.
  • widget-loader.js loads deep-chat from a CDN (unpkg) at runtime rather than bundling it — fine for kicking off, but worth revisiting (self-host or pin a version) before this goes anywhere production-facing.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors