Berkay Orhan
WorkResearchExperienceAboutAskContact
Contact
← All projects

PROJECT / 2025

Municipality Chatbot

AI-Powered Citizen Services

Self-hosted AI chatbot platform for Swedish municipalities with GraphRAG, multi-provider LLM support, and an embeddable React widget. Conversations and the knowledge base stay on the municipality's own infrastructure.

stack
Python 3.11+ · LangChain · LangGraph · FastAPI · PostgreSQL · pgvector · Neo4j · React 19 · TypeScript · Vite · Tailwind CSS v4 · Redis · Docker · Nginx · SSE (Server-Sent Events) · Pydantic · i18next

How it works

  1. municipal sites
    scraped pages and PDFs

  2. pgvector + Neo4j
    chunks and relations

  3. LangGraph agent
    GraphRAG retrieval

  4. widget
    streams answers over SSE

01 / Overview

An AI chatbot designed for Swedish municipalities to help citizens find information about municipal services 24/7. Built with LangChain/LangGraph for orchestration, the platform features GraphRAG technology combining vector search (pgvector) with knowledge graphs (Neo4j) and keyword matching. Supports multiple LLM providers: Google Gemini, OpenAI, Azure OpenAI, Vertex AI, AWS Bedrock, and local models through any OpenAI-compatible endpoint. The embeddable React widget integrates with any website via script tag, JavaScript, or React component. Self-hosted deployment keeps the database, conversation history and knowledge base on municipal infrastructure, and with a local model the prompts stay there too. Includes CLI tools for content ingestion from websites (sitemap), single URLs, PDFs and local files, with OCR for scanned PDFs, knowledge-graph extraction and scheduled sync. Docker Compose profiles, a health endpoint, request logging and conversation persistence for deployment.

02 / Key features

  • –GraphRAG technology combining vector search (pgvector), knowledge graphs (Neo4j), and BM25 keyword search, with a hybrid mode that weights vector and keyword results
  • –Multi-provider LLM support with Google Gemini, OpenAI, Azure OpenAI, Vertex AI, AWS Bedrock, and local models via OpenAI-compatible endpoints, switched in config.yaml through LangChain's init_chat_model
  • –Embeddable React 19 widget with three integration methods: simple script tag, JavaScript initialization, or React component import
  • –Self-hosted architecture built for GDPR: database, conversation history and knowledge base stay on municipal infrastructure, and a local model keeps inference there too
  • –CLI for content ingestion from sitemaps, individual URLs, PDFs, and local files with OCR for scanned PDFs, checkpoint/resume support, and a sync scheduler for nightly updates
  • –Real-time streaming responses via Server-Sent Events (SSE) with LangGraph checkpointing for conversation persistence in PostgreSQL
  • –Multi-language support (Swedish, English, Finnish, Arabic, Turkish, Somali, Spanish, Syriac) with i18next internationalization
  • –Deployable with Docker Compose profiles and an Nginx reverse proxy, with health check endpoints, request logging, Redis-backed or in-memory rate limiting, API key authentication, and per-run model and tool call limits

03 / Challenges

  • –Keeping data on municipal infrastructure while still supporting cloud LLM providers
  • –Building a flexible retrieval system that works for diverse municipal content (policies, forms, organizational info)
  • –Creating a widget that embeds on any website, whichever CMS it runs (WordPress, Drupal, Episerver, Sitevision, custom)
  • –Managing conversation state and streaming responses with LangGraph's async architecture
  • –Designing a CLI ingestion system that handles large websites with resumable checkpointing

04 / Solution

Implemented a layered architecture with LangGraph agent orchestration, PostgreSQL+pgvector for vector search, and Neo4j for relationship mapping. LangChain's init_chat_model provides one interface across all providers. The React widget builds both as a standalone embed script and as an importable component library, supporting multiple integration patterns. SSE streaming with LangGraph checkpointing enables real-time responses while persisting conversation state. The CLI uses BeautifulSoup for web scraping, PyMuPDF for PDFs, and implements checkpoint/resume with progress tracking. Services run in Docker containers with Compose profiles for development and production.

05 / Outcome

A self-hosted chatbot platform a municipality can run on its own servers: the agent, API, ingestion CLI and embeddable widget come together with Docker Compose profiles. The municipality picks its LLM provider (Vertex AI and Bedrock default to EU regions, or a local model keeps inference in-house), and the widget embeds on any site with a script tag. Sitemap sync keeps the knowledge base current, nightly by default.

06 / Services

  • FastAPI Backend

    API server with SSE streaming, thread management, run endpoints, security middleware (rate limiting, API key auth), and a health check. Orchestrates LangGraph agent execution.

    FastAPI · Uvicorn · SSE-Starlette · Pydantic · Redis

  • LangGraph Agent

    AI agent with GraphRAG retrieval (vector, keyword, graph traversal), tool calling, conversation state management, and PostgreSQL checkpointing for persistence and resumption.

    LangChain · LangGraph · PostgreSQL · pgvector · Neo4j

  • React Chat Widget

    Embeddable chat interface with React 19, TypeScript, Tailwind CSS v4, i18next multilingual support, theme customization, and three integration methods (script tag, JS init, React component).

    React 19 · TypeScript · Vite · Tailwind CSS v4 · i18next

  • Ingestion CLI

    Command-line tools for content ingestion from sitemaps, URLs, PDFs, and local files. Features OCR for scanned PDFs, knowledge-graph extraction, checkpoint/resume for large imports, sync analysis, and stats reporting.

    Python · BeautifulSoup · PyMuPDF · HTTPX · Click · Rich · Neo4j

Berkay Orhan© 2026

WorkResearchExperienceCVBack to top ↑