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.
- π 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
- Python 3.8+
- Node.js 16+
- Git
git clone https://github.com/sachin9536/guard-chat.git
cd guard-chatcd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtCreate .env file in backend directory:
GROQ_API_KEY=your_groq_api_key_here
SECRET_KEY=your_secret_key_here
ENVIRONMENT=developmentcd ../frontend
npm install# Terminal 1 - Backend
cd backend
python main.py
# Terminal 2 - Frontend
cd frontend
npm run devVisit http://localhost:5173 to access GuardChat!
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
- 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
- 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
| 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 |
Once running, visit:
- Interactive API Docs:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
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-compose up --builddocker-compose -f docker-compose.yml up -dAccess at http://localhost:80
- 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
# Admin uploads a confidential document
POST /upload
{
"file": "salary_matrix.pdf",
"roles": ["Admin", "Manager"],
"categories": ["HR", "Confidential"]
}# Employee asks about company policy
POST /query
{
"query": "What is the remote work policy?",
"user_role": "Employee"
}# Intern requests access to restricted document
POST /request-access
{
"document_id": "doc-123",
"message": "Need access for project research"
}- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- 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
- π§ Email: sachinchoudharyxyz9@gmail.com
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
Built with β€οΈ by Sachin Choudhary