Spaces:
Configuration error
Configuration error
Delete README.md
Browse files
README.md
DELETED
|
@@ -1,146 +0,0 @@
|
|
| 1 |
-
# Departmental RAG System with Role-Based Access Control
|
| 2 |
-
|
| 3 |
-
A production-ready Streamlit-based RAG (Retrieval-Augmented Generation) application with MongoDB authentication and role-based access control. This application allows users to securely access and query department-specific documents based on their assigned roles.
|
| 4 |
-
|
| 5 |
-

|
| 6 |
-
|
| 7 |
-
## ✨ Features
|
| 8 |
-
|
| 9 |
-
- **Secure Authentication**: MongoDB-based user authentication
|
| 10 |
-
- **Role-Based Access Control (RBAC)**: Granular access to department-specific documents
|
| 11 |
-
- **Efficient Document Retrieval**: ChromaDB vector store with Cohere embeddings
|
| 12 |
-
- **Natural Language Queries**: Powered by Groq's LLM with Cohere embeddings
|
| 13 |
-
- **Modern UI**: Clean, responsive interface with dark/light theme support
|
| 14 |
-
- **Department-Specific Knowledge Bases**: Isolated document repositories for each department
|
| 15 |
-
|
| 16 |
-
## 🛠️ Prerequisites
|
| 17 |
-
|
| 18 |
-
- Python 3.8+
|
| 19 |
-
- MongoDB Atlas account (or local MongoDB instance)
|
| 20 |
-
- Cohere API key (for text embeddings)
|
| 21 |
-
- Groq API key (for LLM, optional but recommended)
|
| 22 |
-
|
| 23 |
-
## 🚀 Quick Start
|
| 24 |
-
|
| 25 |
-
1. **Clone the repository**
|
| 26 |
-
```bash
|
| 27 |
-
git clone https://github.com/Bharath8080/RBAC_RAG_V4.git
|
| 28 |
-
cd RBAC_RAG_V4
|
| 29 |
-
```
|
| 30 |
-
|
| 31 |
-
2. **Set up the environment**
|
| 32 |
-
```bash
|
| 33 |
-
# Install uv (if not already installed)
|
| 34 |
-
pip install uv
|
| 35 |
-
|
| 36 |
-
# Create and activate virtual environment
|
| 37 |
-
uv venv
|
| 38 |
-
.venv\Scripts\activate # On Windows
|
| 39 |
-
# OR
|
| 40 |
-
source .venv/bin/activate # On Unix/macOS
|
| 41 |
-
|
| 42 |
-
# Install dependencies
|
| 43 |
-
uv pip install -r requirements.txt
|
| 44 |
-
```
|
| 45 |
-
|
| 46 |
-
3. **Configure environment variables**
|
| 47 |
-
Create a `.env` file in the project root with the following content:
|
| 48 |
-
```
|
| 49 |
-
# MongoDB Configuration
|
| 50 |
-
MONGO_URI=mongodb+srv://<username>:<password>@<cluster-address>/<database>?retryWrites=true&w=majority
|
| 51 |
-
DB_NAME=rag_system
|
| 52 |
-
|
| 53 |
-
# Cohere API Key (for embeddings)
|
| 54 |
-
COHERE_API_KEY=your_cohere_api_key_here
|
| 55 |
-
|
| 56 |
-
# Optional: Groq API Key (for LLM)
|
| 57 |
-
GROQ_API_KEY=your_groq_api_key_here
|
| 58 |
-
```
|
| 59 |
-
Replace the placeholder values with your actual credentials.
|
| 60 |
-
|
| 61 |
-
4. **Set up the vector store**
|
| 62 |
-
```bash
|
| 63 |
-
python ingest.py
|
| 64 |
-
```
|
| 65 |
-
This will process and index all documents in the `resources/data/` directory.
|
| 66 |
-
|
| 67 |
-
5. **Initialize the database with sample users**
|
| 68 |
-
```bash
|
| 69 |
-
python ingest_db.py
|
| 70 |
-
```
|
| 71 |
-
This will create sample user accounts in your MongoDB database.
|
| 72 |
-
|
| 73 |
-
6. **Run the application**
|
| 74 |
-
```bash
|
| 75 |
-
streamlit run app.py
|
| 76 |
-
```
|
| 77 |
-
|
| 78 |
-
7. **Access the application**
|
| 79 |
-
Open your browser and navigate to `http://localhost:8501`
|
| 80 |
-
|
| 81 |
-
## 👥 Default User Accounts
|
| 82 |
-
|
| 83 |
-
| Username | Password | Department |
|
| 84 |
-
|----------|-------------|-------------|
|
| 85 |
-
| tony | password123 | engineering |
|
| 86 |
-
| bruce | securepass | marketing |
|
| 87 |
-
| sam | financepass | finance |
|
| 88 |
-
| natasha | hrpass123 | hr |
|
| 89 |
-
|
| 90 |
-
## 📁 Project Structure
|
| 91 |
-
|
| 92 |
-
```
|
| 93 |
-
RBAC_RAG_V4/
|
| 94 |
-
├── .env.example # Example environment variables
|
| 95 |
-
├── app.py # Main Streamlit application
|
| 96 |
-
├── database.py # Database connection and user management
|
| 97 |
-
├── ingest.py # Document processing and vector store creation
|
| 98 |
-
├── ingest_db.py # Initialize MongoDB with sample users
|
| 99 |
-
├── requirements.txt # Python dependencies
|
| 100 |
-
├── resources/
|
| 101 |
-
│ └── data/ # Department-specific documents
|
| 102 |
-
│ ├── engineering/
|
| 103 |
-
│ ├── finance/
|
| 104 |
-
│ ├── hr/
|
| 105 |
-
│ └── marketing/
|
| 106 |
-
└── chroma_db/ # ChromaDB vector store (created after first run)
|
| 107 |
-
```
|
| 108 |
-
|
| 109 |
-
## 🔧 Configuration
|
| 110 |
-
|
| 111 |
-
### Environment Variables
|
| 112 |
-
|
| 113 |
-
- `MONGO_URI`: MongoDB connection string
|
| 114 |
-
- `DB_NAME`: Database name (default: `rag_system`)
|
| 115 |
-
- `COHERE_API_KEY`: Required for text embeddings
|
| 116 |
-
- `GROQ_API_KEY`: Required for LLM responses (falls back to local model if not provided)
|
| 117 |
-
|
| 118 |
-
### Adding New Users
|
| 119 |
-
|
| 120 |
-
1. Run the `ingest_db.py` script with new user data
|
| 121 |
-
2. Or add users directly to MongoDB in the `users` collection
|
| 122 |
-
|
| 123 |
-
### Adding New Documents
|
| 124 |
-
|
| 125 |
-
1. Place documents in the appropriate department folder under `resources/data/`
|
| 126 |
-
2. Run `python ingest.py` to update the vector store
|
| 127 |
-
|
| 128 |
-
## 🛡️ Security Notes
|
| 129 |
-
|
| 130 |
-
- Always store sensitive information in environment variables, never in code
|
| 131 |
-
- Use strong, unique passwords for MongoDB access
|
| 132 |
-
- Regularly update your dependencies for security patches
|
| 133 |
-
- Consider implementing rate limiting in production
|
| 134 |
-
- Enable MongoDB network access restrictions
|
| 135 |
-
|
| 136 |
-
## 📄 License
|
| 137 |
-
|
| 138 |
-
This project is part of the Codebasics Resume Project Challenge.
|
| 139 |
-
|
| 140 |
-
## 🙏 Acknowledgments
|
| 141 |
-
|
| 142 |
-
- [Streamlit](https://streamlit.io/) for the web framework
|
| 143 |
-
- [ChromaDB](https://www.trychroma.com/) for vector storage
|
| 144 |
-
- [Cohere](https://cohere.com/) for embeddings
|
| 145 |
-
- [Groq](https://groq.com/) for LLM inference
|
| 146 |
-
- [MongoDB](https://www.mongodb.com/) for user management
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|