Skip to content

NelakaWith/de-clerk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

166 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– DeClerk

Live Demo Deployment Status License: MIT Node.js Vue.js

Express.js Vite OpenRouter Fuse.js Conventional Commits

Advanced AI-powered Legal RAG & Multi-Provider Chatbot

DeClerk is a sophisticated full-stack chatbot solution designed for enterprise-grade Retrieval-Augmented Generation (RAG). It features deep structural analysis of PDF documents, semantic vector search with pgvector, and a multi-provider AI engine supporting Gemini, Groq, and OpenRouter.

πŸ”— Live Demo

Explore DeClerk Live

πŸ“‹ Overview

DeClerk goes beyond simple keyword matching. It implements a multi-layered approach to information retrieval and conversation:

  • Intelligent RAG: Semantic search using pgvector and local embedding generation with Transformers.js.
  • Structural PDF Analysis: Automatically detects "Parts" and "Chapters" in complex (e.g., legal) documents for contextual responses.
  • Multi-Provider AI: Seamlessly switch between Google Gemini 1.5, Groq (Llama 3/Mixtral), or OpenRouter models.
  • Fuzzy Search Fallback: High-performance local search using Fuse.js for exact and near-match queries.

Built with modern web standards, DeClerk demonstrates production-ready patterns for AI integration, document processing, and reactive UI design.

✨ Key Features

🧠 Advanced RAG System

  • Vector search: Deep semantic understanding using pgvector on Neon PostgreSQL.
  • Local Embeddings: Privacy-focused embedding generation using @xenova/transformers.
  • Structural Awareness: Extracts hierarchical information (Chapter/Section) from PDFs to provide precise citations.
  • Smart Chunking: Semantically-aware text splitting with overlap for better context preservation.

πŸ€– Multi-Provider AI Engine

  • Google Gemini: Integration with Gemini 1.5 Pro/Flash for high-reasoning tasks.
  • Groq API: Blazing fast responses using Llama 3 and Mixtral models.
  • OpenRouter: Unified access point for a wide range of open-source LLMs.
  • Stateful Chats: Persistent conversation history for context-aware interactions.

🎨 Premium Frontend

  • Vue 3 Composition API: Modular, reactive component architecture.
  • Dynamic File Uploads: Real-time PDF processing and indexing via the UI.
  • Rich Interaction: Fluid typing indicators, markdown rendering, and smooth transitions.
  • Responsive Mastery: Tailored experiences for both desktop and mobile users.

πŸ”§ Developer First

  • Scalable Architecture: Clean separation of services, controllers, and database layers.
  • Automated Schema: Self-initializing database tables and vector extensions on startup.
  • Health Monitoring: Built-in endpoints for service metrics and connectivity status.

πŸ› οΈ Tech Stack

Frontend

  • Vue 3 - Framework with Composition API
  • Vite - Modern frontend tooling
  • Axios - Promise-based HTTP client
  • CSS3/Animations - Custom-crafted premium aesthetics

Backend

  • Node.js & Express - Efficient server-side runtime and framework
  • Neon / PostgreSQL - Serverless database with pgvector support
  • Fuse.js - Lightweight fuzzy search for local data
  • PDF-parse - Robust PDF text extraction

AI & Embeddings

  • Gemini API - Google's latest generative models
  • Groq API - Low-latency LLM inference
  • Transformers.js - Local ML for embedding generation
  • OpenRouter - Aggregated AI model gateway

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Neon.tech account (or any PostgreSQL with pgvector)
  • One or more AI API Keys (Gemini, Groq, or OpenRouter)

Installation

  1. Clone the repository

    git clone https://github.com/NelakaWith/de-clerk.git
    cd de-clerk
  2. Install all dependencies

    npm install
  3. Configure Environment Variables

    Navigate to the backend directory and create your .env file:

    cd backend
    cp .env.example .env

    Add your credentials to .env:

    • NEON_DATABASE_URL: Your PostgreSQL connection string.
    • GEMINI_API_KEY: [Optional] Google AI Studio key.
    • GROQ_API_KEY: [Optional] Groq Console key.
    • OPENROUTER_API_KEY: [Optional] OpenRouter key.
  4. Launch Development Servers

    Terminal 1 (Backend):

    cd backend
    npm run dev

    Terminal 2 (Frontend):

    cd frontend
    npm run dev
  5. Access Application

Windows Quick Launch

Simply execute the included batch file for a onend-click setup:

run-demo.bat

πŸ“š Project Structure

declerk/
β”œβ”€β”€ backend/               # Express.js Server
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/   # Request logic handlers
β”‚   β”‚   β”œβ”€β”€ routes/        # API route definitions
β”‚   β”‚   β”œβ”€β”€ services/      # RAG, Search, and AI logic
β”‚   β”‚   └── db/            # Database schema & connection
β”‚   └── data/              # Default JSON knowledge bases
β”œβ”€β”€ frontend/              # Vue 3 Application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # Reusable UI components
β”‚   β”‚   └── composables/   # Shared reactive logic
β”œβ”€β”€ documents/             # Storage for local PDF sources
β”œβ”€β”€ scripts/               # Maintenance and utility scripts
└── docker-compose.yml     # Containerization config

πŸ§ͺ API Endpoints

Method Endpoint Description
POST /api/chat Intelligent hybrid search query
POST /api/chat/llm Multi-model AI conversation
POST /api/rag/upload Upload and vectorize PDF document
GET /status Real-time service usage & metrics
GET /health System connectivity health check

🀝 Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ‘¨β€πŸ’» Author

Nelaka Withanage

πŸ“„ License

Distributed under the MIT License. See LICENSE for more information.


⭐ Star this repository if you found it helpful!

Built with excellence using Vue.js, Express.js, and next-gen AI.

About

A modern AI-powered chatbot with intelligent knowledge base search and LLM integration, built with Vue 3 and Node.js.

Topics

Resources

License

Stars

Watchers

Forks

Contributors