Skip to content

AI-powered document chat system with role-based access control

Notifications You must be signed in to change notification settings

sachin9536/guard-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GuardChat πŸ›‘οΈπŸ’¬

An intelligent document chat system that enables secure, role-based conversations with organizational documents. Users can query company policies, technical documentation, and confidential files through natural language, with AI-powered responses that respect access permissions and maintain data security.

GuardChat Demo Python React FastAPI

✨ Key Features

  • πŸ” Role-based Access Control - Admin, Manager, Employee, Intern permissions
  • πŸ€– AI-Powered Q&A - Natural language queries using Groq LLaMA 3.1
  • πŸ“„ Multi-format Support - PDF, DOCX, TXT, MD document processing
  • πŸ” Semantic Search - FAISS vector store for intelligent document retrieval
  • πŸ’¬ Real-time Chat - WebSocket-powered conversations with history
  • πŸ“Š Admin Dashboard - Document management and audit logging
  • 🎨 Modern UI - Glassmorphism design with dark/light themes
  • πŸ”’ Security First - JWT authentication and comprehensive audit trails

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • Git

1. Clone Repository

git clone https://github.com/sachin9536/guard-chat.git
cd guard-chat

2. Backend Setup

cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

3. Environment Configuration

Create .env file in backend directory:

GROQ_API_KEY=your_groq_api_key_here
SECRET_KEY=your_secret_key_here
ENVIRONMENT=development

4. Frontend Setup

cd ../frontend
npm install

5. Run Application

# Terminal 1 - Backend
cd backend
python main.py

# Terminal 2 - Frontend
cd frontend
npm run dev

Visit http://localhost:5173 to access GuardChat!

πŸ—οΈ Architecture

GuardChat/
β”œβ”€β”€ backend/                 # FastAPI backend
β”‚   β”œβ”€β”€ main.py             # API server
β”‚   β”œβ”€β”€ database.py         # SQLite database
β”‚   β”œβ”€β”€ vector_store.py     # FAISS vector operations
β”‚   β”œβ”€β”€ auth.py             # JWT authentication
β”‚   └── indexing.py         # Document processing
β”œβ”€β”€ frontend/               # React frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # UI components
β”‚   β”‚   β”œβ”€β”€ pages/          # Application pages
β”‚   β”‚   └── utils/          # API utilities
β”œβ”€β”€ demo-documents/         # Sample documents
└── docker-compose.yml      # Docker deployment

πŸ”§ Built With

Backend

  • FastAPI - High-performance Python web framework
  • SQLite - Lightweight database for data persistence
  • FAISS - Facebook AI Similarity Search for vector operations
  • Groq API - LLaMA 3.1 language model integration
  • LangChain - Document processing and chunking
  • Sentence Transformers - Text embeddings (all-mpnet-base-v2)
  • python-docx - DOCX document processing
  • PyPDF2 - PDF document processing
  • WebSockets - Real-time communication
  • JWT - Secure authentication tokens

Frontend

  • React 18 - Modern UI library
  • Vite - Fast build tool and dev server
  • Tailwind CSS - Utility-first CSS framework
  • Lucide React - Beautiful icon library
  • Axios - HTTP client for API calls

πŸ‘₯ Default Users

Username Password Role Access Level
admin admin123 Admin Full system access
manager manager123 Manager Department documents
employee employee123 Employee General documents
intern intern123 Intern Public documents only

πŸ“š API Documentation

Once running, visit:

  • Interactive API Docs: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

Key Endpoints

POST /login              # User authentication
POST /query              # Document Q&A
POST /upload             # Document upload
GET  /documents          # List documents
POST /request-access     # Request document access
GET  /conversations      # Chat history

🐳 Docker Deployment

Development

docker-compose up --build

Production

docker-compose -f docker-compose.yml up -d

Access at http://localhost:80

πŸ”’ Security Features

  • JWT Authentication - Secure token-based auth
  • Role-based Access Control - Granular permissions
  • Audit Logging - Complete activity tracking
  • Input Validation - SQL injection prevention
  • Rate Limiting - API abuse protection
  • CORS Configuration - Cross-origin security

πŸ“– Usage Examples

Document Upload

# Admin uploads a confidential document
POST /upload
{
  "file": "salary_matrix.pdf",
  "roles": ["Admin", "Manager"],
  "categories": ["HR", "Confidential"]
}

Query Documents

# Employee asks about company policy
POST /query
{
  "query": "What is the remote work policy?",
  "user_role": "Employee"
}

Access Request

# Intern requests access to restricted document
POST /request-access
{
  "document_id": "doc-123",
  "message": "Need access for project research"
}

🀝 Contributing

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

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Groq for lightning-fast LLaMA inference
  • FAISS for efficient vector similarity search
  • LangChain for document processing utilities
  • FastAPI for the excellent web framework
  • React community for amazing UI components

πŸ“ž Support


Built with ❀️ by Sachin Choudhary

About

AI-powered document chat system with role-based access control

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published