Skip to content

Os-humble-man/RAGify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

76 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RAGify β€” Enterprise Documentation Chatbot

An intelligent RAG-based chatbot for internal documentation
Ask questions in natural language across your company’s knowledge base (Google Docs, Confluence, PDFs, Markdown).
Get precise, sourced answers with deep links to relevant procedures, forms, or policies.


πŸ“‹ Table of Contents

  1. Overview
  2. Business Use Cases
  3. Core Features (AI & RAG)
  4. Technologies Used
  5. Architecture
  6. Installation & Configuration
  7. Usage
  8. Available Scripts
  9. Project Structure
  10. Skills Demonstrated
  11. Roadmap & Future Improvements
  12. Author

🎯 Overview

RAGify is a full-stack Retrieval-Augmented Generation (RAG) application designed for enterprise use.
It allows employees to query internal documentation in natural language β€” returning accurate, context-rich, and sourced answers.

Example Workflow

πŸ§‘β€πŸ’Ό β€œHow do I request leave?”
The chatbot retrieves the HR policy, cites the official document, and provides the link to the correct form.


πŸ’Ό Business Use Cases

RAGify streamlines access to internal knowledge across departments:

  • 🧾 HR β€” Leave requests, onboarding, company policies
  • πŸ’» IT β€” Account setup, device policies, troubleshooting
  • βš–οΈ Compliance β€” Regulations, audit procedures, GDPR documentation
  • πŸ“ˆ Operations β€” Workflows, templates, forms, and SOPs

RAGify ensures every employee gets instant, reliable answers without searching through folders or outdated docs.


✨ Core Features (AI & RAG)

Category Features
πŸ’¬ Chat Experience Real-time streaming responses with Server-Sent Events (SSE)
πŸ“š RAG Engine Semantic search using pgvector + contextual prompt enrichment
πŸ”€ Dual Mode Toggle between standard AI chat and RAG-enhanced mode with document context
πŸ”— Sourced Answers RAG mode provides context from internal documents (HR, IT, Security, Stock procedures)
πŸ—‚ Conversation Management Create, organize, favorite, and move conversations into folders
πŸ” Authentication Email/password + OAuth 2.0 (Google & GitHub)
βš™οΈ Configurable AI Stack OpenAI and OpenRouter support with model selection
🧩 Document Indexing PDF parsing and automatic embedding generation with chunk-based storage
οΏ½ Analytics & Monitoring Token usage tracking, conversation analytics, and system logging
🎨 Modern UI Responsive design with dark/light mode, Tailwind CSS 4, and Radix UI components
πŸ“ Folder Organization Organize conversations by topics or projects
πŸ”’ Security Helmet, CORS, rate limiting, JWT tokens, bcrypt password hashing
πŸ“„ API Documentation Complete Swagger/OpenAPI documentation
🎯 Business Ready User settings, templates, plugins architecture, notifications, exports, and sharing capabilities

🏒 Technologies Used

Frontend

  • React 19, TypeScript, Vite
  • TailwindCSS 4, Radix UI (Dialog, Avatar, Dropdown, Switch, Tooltip, Separator, Collapsible)
  • Lucide React for icons
  • TanStack Query (React Query) for state management
  • Zustand for global state
  • Axios for API communication

Backend

  • Bun Runtime, Express 5, TypeScript
  • Prisma ORM + PostgreSQL + pgvector
  • InversifyJS for dependency injection
  • Passport.js with OAuth 2.0 (Google & GitHub authentication)
  • Zod for schema validation
  • JWT for session management
  • Winston for logging
  • Swagger for API documentation
  • Helmet, CORS, Rate Limiting for security

RAG Engine

  • Embedding generation via OpenAI API (text-embedding-3-small)
  • Vector search with pgvector extension
  • Tiktoken for token counting
  • Automatic context injection in LLM prompts
  • Support for OpenRouter and OpenAI models
  • Document processing: PDF.js for PDF parsing

Dev Tools & Infrastructure

  • Monorepo structure with workspaces
  • ESLint, Prettier for code quality
  • Husky, lint-staged for pre-commit hooks
  • Concurrently for parallel dev server orchestration
  • Nodemailer for email notifications
  • bcrypt for password hashing

πŸ— Architecture

πŸ”„ Technical Workflow

  1. The user submits a question through the React UI.
  2. The server (Express/Bun) handles the query:
    • Generates embeddings for the input.
    • Performs a semantic vector search in pgvector.
    • Constructs a context-enriched prompt.
  3. The AI model (OpenAI/OpenRouter) produces a streamed response.
  4. The frontend displays the answer in real time, including citations and document links.

🧩 Structural Overview

RAGify/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ client/                    # React + Vite frontend
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ api/              # API client layer
β”‚   β”‚   β”‚   β”œβ”€β”€ components/       # React components (UI + shared)
β”‚   β”‚   β”‚   β”œβ”€β”€ contexts/         # React contexts (RagMode, Auth)
β”‚   β”‚   β”‚   β”œβ”€β”€ hooks/            # Custom hooks (queries, mutations)
β”‚   β”‚   β”‚   β”œβ”€β”€ pages/            # Route pages
β”‚   β”‚   β”‚   β”œβ”€β”€ store/            # Zustand stores
β”‚   β”‚   β”‚   └── types/            # TypeScript types
β”‚   β”‚   └── package.json
β”‚   β”‚
β”‚   └── server/                    # Express/Bun backend
β”‚       β”œβ”€β”€ assets/
β”‚       β”‚   └── documents/        # Internal company docs (PDF, TXT)
β”‚       β”œβ”€β”€ controllers/          # Route controllers
β”‚       β”œβ”€β”€ services/             # Business logic (Chat, RAG, Auth, User)
β”‚       β”œβ”€β”€ repositories/         # Database access layer
β”‚       β”œβ”€β”€ routes/               # API routes
β”‚       β”œβ”€β”€ middleware/           # Express middleware
β”‚       β”œβ”€β”€ strategies/           # Passport OAuth strategies
β”‚       β”œβ”€β”€ utils/                # Helper utilities (JWT, Embedding, Tokens)
β”‚       β”œβ”€β”€ prisma/
β”‚       β”‚   β”œβ”€β”€ schema.prisma     # Database schema
β”‚       β”‚   └── migrations/       # Database migrations
β”‚       β”œβ”€β”€ scripts/              # Setup & RAG indexing scripts
β”‚       β”œβ”€β”€ docs/                 # Swagger API documentation
β”‚       └── package.json
β”‚
β”œβ”€β”€ index.ts                       # Root dev orchestrator (concurrently)
β”œβ”€β”€ package.json                   # Root workspace config
β”œβ”€β”€ .husky/                        # Git hooks
β”œβ”€β”€ DOCUMENT_RAG_QUICKSTART.md     # RAG setup guide
β”œβ”€β”€ RAG_INTEGRATION_GUIDE.md       # RAG implementation docs
β”œβ”€β”€ RAG_MODE_USAGE.md              # RAG mode usage guide
└── README.md

βš™οΈ Installation & Configuration

Prerequisites

  • Node.js 20+ or Bun
  • PostgreSQL (with pgvector extension)
  • OpenAI or OpenRouter API Key

Setup

# Clone the repository
git clone https://github.com/Os-humble-man/ai-app
cd ai-app

# Install dependencies (using Bun)
bun install

# Setup server environment
cd packages/server
cp .env.example .env
# Edit .env and add:
# - DATABASE_URL (PostgreSQL with pgvector)
# - OPENAI_API_KEY or OPENROUTER_API_KEY
# - JWT_SECRET
# - OAuth credentials (GOOGLE_CLIENT_ID, GITHUB_CLIENT_ID, etc.)

# Generate Prisma client
bun run prisma:generate

# Run database migrations
bun run prisma:dev

# (Optional) Prepare documents for RAG
bun run prepare-docs

# Go back to root
cd ../..

# Start both client and server in development mode
bun run dev

Environment Variables

Create a .env file in packages/server/ with the following:

# Database
DATABASE_URL="postgresql://user:password@localhost:5432/ai_app?schema=public"

# OpenAI / OpenRouter
OPENAI_API_KEY="sk-..."
OPENROUTER_API_KEY="sk-or-..."
OPENROUTER_BASE_URL="https://openrouter.ai/api/v1"

# JWT
JWT_SECRET="your-secret-key"

# OAuth (Google)
GOOGLE_CLIENT_ID="..."
GOOGLE_CLIENT_SECRET="..."
GOOGLE_CALLBACK_URL="http://localhost:3000/api/auth/google/callback"

# OAuth (GitHub)
GITHUB_CLIENT_ID="..."
GITHUB_CLIENT_SECRET="..."
GITHUB_CALLBACK_URL="http://localhost:3000/api/auth/github/callback"

# Server
PORT=3000
CLIENT_URL="http://localhost:5173"

# Email (optional)
SMTP_HOST="smtp.gmail.com"
SMTP_PORT=587
SMTP_USER="your-email@gmail.com"
SMTP_PASS="your-app-password"

For more details, see:

  • DOCUMENT_RAG_QUICKSTART.md - Quick start guide for RAG setup
  • RAG_INTEGRATION_GUIDE.md - Complete RAG integration documentation
  • RAG_MODE_USAGE.md - Guide on using RAG mode
  • DATABASE_SETUP.md - Database configuration guide

πŸš€ Usage

Starting the Application

# Start both client (port 5173) and server (port 3000)
bun run dev

Accessing the Application

  1. Frontend: Visit http://localhost:5173
  2. Backend API: http://localhost:3000
  3. API Documentation: http://localhost:3000/api-docs (Swagger UI)
  4. Prisma Studio: cd packages/server && bun run prisma:studio

Using the Chat

  1. Sign up or Log in (Email/Password, Google, or GitHub)
  2. Toggle RAG Mode in the header to switch between:
    • πŸ’‘ Standard AI mode β†’ General-purpose chatbot responses
    • πŸ“˜ RAG mode β†’ Context-aware responses using internal documents
  3. Ask questions like:
    • "Comment demander un congΓ©?" (How do I request leave?)
    • "Quelle est la procΓ©dure de gestion des stocks?" (What is the stock management procedure?)
  4. Organize conversations into folders
  5. View conversation history in the sidebar

Available Scripts

Root Level

bun run dev        # Start both client and server
bun run format     # Format code with Prettier

Server (packages/server/)

bun run dev                # Start server in watch mode
bun run start              # Start server (production)
bun run prisma:dev         # Run database migrations
bun run prisma:studio      # Open Prisma Studio
bun run prisma:generate    # Generate Prisma Client
bun run prepare-docs       # Process and index documents for RAG
bun run test-rag           # Test RAG functionality
bun run fix-pgvector       # Fix pgvector extension issues

Client (packages/client/)

bun run dev        # Start Vite dev server
bun run build      # Build for production
bun run preview    # Preview production build
bun run lint       # Run ESLint

πŸ“Š Project Structure

Key Directories

  • /packages/client/ β€” React 19 application with Vite

    • src/api/ β€” API client layer (Axios)
    • src/components/ β€” Reusable UI components
    • src/contexts/ β€” React Context providers (RagMode, Auth)
    • src/hooks/ β€” React Query hooks for data fetching
    • src/store/ β€” Zustand global state management
  • /packages/server/ β€” Express/Bun backend API

    • controllers/ β€” Request handlers
    • services/ β€” Business logic (ChatService, RagService, AuthService)
    • repositories/ β€” Database access layer
    • routes/ β€” API route definitions
    • middleware/ β€” Error handling, validation, logging
    • strategies/ β€” Passport OAuth strategies
    • utils/ β€” Helper functions (JWT, Embeddings, Tokens)
    • prisma/ β€” Database schema and migrations
    • assets/documents/ β€” Internal company documents (PDF, TXT)
    • scripts/ β€” Document processing and RAG indexing utilities
  • Root configuration files

    • index.ts β€” Concurrently orchestrator for dev mode
    • package.json β€” Monorepo workspace configuration
    • .husky/ β€” Git hooks for code quality

πŸŽ“ Skills Demonstrated

Area Capabilities
🧠 RAG & AI Integration Semantic search, embeddings (OpenAI), pgvector, context injection, dual-mode chatbot
🌐 Full-Stack Architecture React 19 + Express 5 monorepo with Bun runtime, TypeScript throughout
🧩 Backend Engineering RESTful API design, Prisma ORM, PostgreSQL, InversifyJS DI, layered architecture
πŸ” Authentication & Security JWT, OAuth 2.0 (Passport.js), bcrypt, Helmet, CORS, rate limiting
πŸš€ Performance Real-time SSE streaming, React Query for caching, async/await optimization
🧰 DevOps & Code Quality Husky, lint-staged, ESLint, Prettier, Git hooks, workspace management
🎨 Professional UX/UI Tailwind CSS 4, Radix UI primitives, responsive design, dark mode support
οΏ½ Data Management Vector databases, document chunking, embedding generation, token counting
🧾 Documentation Swagger/OpenAPI, comprehensive guides, inline documentation
πŸ—οΈ Design Patterns Repository pattern, service layer, dependency injection, context providers

🧭 Roadmap & Future Improvements

In Progress

  • βœ… RAG mode with document context
  • βœ… OAuth authentication (Google & GitHub)
  • βœ… Folder organization system
  • βœ… Real-time streaming responses
  • βœ… Swagger API documentation

Planned Features

  • πŸ“‘ Source Citations - Display document sources with download links in RAG responses
  • πŸ“Š Enhanced Analytics - Dashboard for token usage, conversation metrics, popular queries
  • πŸ” Document Versioning - Track document updates and maintain version history
  • βš™οΈ Performance Optimization - Embedding cache & HNSW index for faster vector search
  • 🌍 Multi-language Support - i18n integration for international teams
  • πŸ”’ RBAC - Role-based access control for document permissions
  • πŸ’¬ Feedback System - User ratings for AI responses to improve quality
  • πŸ“€ Export & Share - Export conversations to PDF/Markdown, share with team members
  • πŸ”” Real-time Notifications - WebSocket integration for live updates
  • 🎨 Custom Themes - Brand customization and white-labeling
  • πŸ”Œ Plugin System - Extensible architecture for custom integrations
  • πŸ“± Mobile Optimization - Progressive Web App (PWA) capabilities
  • πŸ§ͺ Testing Suite - Comprehensive unit and integration tests

πŸ‘€ Author

Oscar Kanangila
πŸš€ Web Developer

Expertise:

  • 🧠 Retrieval-Augmented Generation (RAG) & LLM Integration
  • βš›οΈ React, TypeScript, Modern Frontend Architecture
  • πŸ”§ Node.js, Express, Bun Runtime
  • πŸ—„οΈ PostgreSQL, Prisma ORM, Vector Databases
  • πŸ” OAuth, JWT, Enterprise Security
  • πŸ—οΈ Monorepo Architecture, Dependency Injection
  • πŸ“Š API Design, Swagger Documentation

Connect:


πŸ“š Additional Documentation

This project includes comprehensive documentation:


⭐️ Contribute

Contributions, feedback, and ideas are welcome!

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow the existing code style (ESLint + Prettier)
  • Write meaningful commit messages
  • Update documentation when adding features
  • Test your changes before submitting

🧩 License

This project is distributed under the MIT License.


πŸ™ Acknowledgments

  • OpenAI for GPT models and embeddings API
  • OpenRouter for multi-model LLM routing
  • Prisma for excellent ORM tooling
  • Radix UI for accessible component primitives
  • SHADCN UI for accessible component primitives
  • TailwindCSS for utility-first styling
  • Bun for blazing fast JavaScript runtime

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages