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.
- Overview
- Business Use Cases
- Core Features (AI & RAG)
- Technologies Used
- Architecture
- Installation & Configuration
- Usage
- Available Scripts
- Project Structure
- Skills Demonstrated
- Roadmap & Future Improvements
- Author
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.
π§βπΌ βHow do I request leave?β
The chatbot retrieves the HR policy, cites the official document, and provides the link to the correct form.
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.
| 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 |
- 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
- 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
- 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
- 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
- The user submits a question through the React UI.
- The server (Express/Bun) handles the query:
- Generates embeddings for the input.
- Performs a semantic vector search in
pgvector. - Constructs a context-enriched prompt.
- The AI model (OpenAI/OpenRouter) produces a streamed response.
- The frontend displays the answer in real time, including citations and document links.
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
- Node.js 20+ or Bun
- PostgreSQL (with
pgvectorextension) - OpenAI or OpenRouter API Key
# 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 devCreate 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
# Start both client (port 5173) and server (port 3000)
bun run dev- Frontend: Visit http://localhost:5173
- Backend API: http://localhost:3000
- API Documentation: http://localhost:3000/api-docs (Swagger UI)
- Prisma Studio:
cd packages/server && bun run prisma:studio
- Sign up or Log in (Email/Password, Google, or GitHub)
- Toggle RAG Mode in the header to switch between:
- π‘ Standard AI mode β General-purpose chatbot responses
- π RAG mode β Context-aware responses using internal documents
- 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?)
- Organize conversations into folders
- View conversation history in the sidebar
bun run dev # Start both client and server
bun run format # Format code with Prettierbun 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 issuesbun run dev # Start Vite dev server
bun run build # Build for production
bun run preview # Preview production build
bun run lint # Run ESLint-
/packages/client/β React 19 application with Vitesrc/api/β API client layer (Axios)src/components/β Reusable UI componentssrc/contexts/β React Context providers (RagMode, Auth)src/hooks/β React Query hooks for data fetchingsrc/store/β Zustand global state management
-
/packages/server/β Express/Bun backend APIcontrollers/β Request handlersservices/β Business logic (ChatService, RagService, AuthService)repositories/β Database access layerroutes/β API route definitionsmiddleware/β Error handling, validation, loggingstrategies/β Passport OAuth strategiesutils/β Helper functions (JWT, Embeddings, Tokens)prisma/β Database schema and migrationsassets/documents/β Internal company documents (PDF, TXT)scripts/β Document processing and RAG indexing utilities
-
Root configuration files
index.tsβ Concurrently orchestrator for dev modepackage.jsonβ Monorepo workspace configuration.husky/β Git hooks for code quality
| 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 |
- β RAG mode with document context
- β OAuth authentication (Google & GitHub)
- β Folder organization system
- β Real-time streaming responses
- β Swagger API documentation
- π 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
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:
- GitHub: @Os-humble-man
- Project: RAGify
This project includes comprehensive documentation:
- DOCUMENT_RAG_QUICKSTART.md - Quick start guide for RAG implementation
- RAG_INTEGRATION_GUIDE.md - Detailed RAG integration documentation
- RAG_MODE_USAGE.md - How to use and implement RAG mode
- DATABASE_SETUP.md - Database configuration and migrations
- CONVERSATION_FILTERING.md - Conversation management features
- FOLDER_FEATURES.md - Folder organization system
- FEATURES_ROADMAP.md - Detailed feature roadmap
Contributions, feedback, and ideas are welcome!
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the existing code style (ESLint + Prettier)
- Write meaningful commit messages
- Update documentation when adding features
- Test your changes before submitting
This project is distributed under the MIT License.
- 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