A high-performance, security-first RAG (Retrieval-Augmented Generation) engine designed to analyze complex JSON datasets while enforcing strict data access policies. Optimized for ERP integrations and VPS deployment.
-
PBAC (Policy-Based Access Control)
Restricts AI knowledge based on user roles (Admin, Manager, Staff, etc.) -
JWT Authentication
Integrates with external ERP tokens for role-based identity -
Role-Isolated Vector DBs
Separate FAISS indexes per role to prevent data leakage -
Dynamic Chain Construction
AI pipeline adapts dynamically based on user permissions
User Query + JWT
↓
[Nginx Proxy]
↓
[FastAPI Engine (PBAC Layer)]
↓
Check Role Index
↓
[Role-Specific FAISS]
↓
[Re-Ranker (Flashrank)]
↓
[Ollama Local LLM]
DR_AIJSONA/
├── data/ # Raw JSON files
├── schemas/ # JSON schema definitions
├── policy.json # PBAC rules
├── faiss_indexes/ # Role-based vector DBs
├── src/
│ ├── main.py # API + security middleware
│ ├── brain.py # Multi-role RAG logic
│ ├── loader.py # Policy-aware loader
│ └── __init__.py
├── Dockerfile
└── docker-compose.yml
Update your environment:
JWT_SECRET=your_erp_jwt_signing_key
OLLAMA_BASE_URL=http://10.73.7.198:11434curl -X POST http://localhost:8000/retrain- Reads
policy.json - Builds isolated FAISS indexes per role
Endpoint: /ask
Method: POST
Headers:
Authorization: Bearer <JWT_TOKEN>
Request:
{
"question": "What is the total revenue for this quarter?"
}👉 Response is filtered based on role permissions.
Endpoint: /retrain
Method: POST
- Rebuilds all role-based indexes
- Required after data/policy updates
| Host Path | Container Path | Purpose |
|---|---|---|
| ./data | /app/data | Raw datasets |
| ./policy.json | /app/policy.json | Access rules |
| ./faiss_indexes | /app/faiss_indexes | Secure vector DB |
| ./cache_data | /app/cache_data | Performance cache |
| Scenario | Logic | Response Time |
|---|---|---|
| Cached Answer | Exact match | < 10ms |
| Semantic Match | Vector similarity | < 150ms |
| Full RAG Cycle | PBAC + LLM | 1.5s – 3s |
- Zero Cloud Leakage: Fully local inference via Ollama
- Memory Isolation: Role-based FAISS separation
- Strict Access Control: Policy-driven data visibility
- Uses existing ERP JWT authentication
- Maps roles directly to AI access layers
- Enables secure “Ask Your Data” feature
MIT License
Contributions and improvements are welcome!
Danuja Dilanka
Optimized for Enterprise ERP Systems
