A comprehensive, bilingual (English/Malayalam) document management system for Kochi Metro Rail Limited (KMRL) with AI-powered features including OCR, summarization, translation, and intelligent routing.
##Features
- Universal Document Intake: Email, WhatsApp, SharePoint, direct upload, mobile camera
- Bilingual OCR: English and Malayalam text extraction using Google Vision API
- AI Processing: Summarization, keyword extraction, bidirectional ENβML translation
- Smart Classification: Auto-categorization (HR, Safety, Engineering, Regulatory, etc.)
- Intelligent Routing: Automatic assignment to relevant departments
- Audit Trail: Complete immutable compliance tracking with role-based access
- Web Dashboard: Responsive, accessible interface with dark/light mode
- Mobile App: PWA with camera integration, offline-first sync
- Bilingual Support: Seamless English/Malayalam toggle throughout
- Voice Interface: Speech queries in both languages
- AI Chatbot: Document Q&A with source citations
- Knowledge Graph: Visual exploration of document relationships
- Performance Dashboards: SLA tracking, compliance metrics
- Visual Analytics: Document trends, department performance
- Knowledge Visualization: Interactive relationship graphs
- Real-time Monitoring: Processing status, pending items
- Frontend: Next.js 14, React, TypeScript, Tailwind CSS
- Backend: Next.js API Routes, FastAPI (optional)
- Database: PostgreSQL with full-text search
- Cache: Redis for sessions and temporary data
- AI Services: Google Vision API, Google Translate API
- Deployment: Docker, Nginx, SSL/TLS
``` βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β Web Client β β Mobile Client β β External APIs β β (Next.js) β β (PWA) β β (Email/WhatsApp)β βββββββββββ¬ββββββββ βββββββββββ¬ββββββββ βββββββββββ¬ββββββββ β β β ββββββββββββββββββββββββΌβββββββββββββββββββββββ β βββββββββββββββ΄ββββββββββββ β Nginx Proxy β β (Load Balancer/SSL) β βββββββββββββββ¬ββββββββββββ β βββββββββββββββ΄ββββββββββββ β Next.js Application β β (API Routes + UI) β βββββββββββββββ¬ββββββββββββ β βββββββββββββββββββββββββΌββββββββββββββββββββββββ β β β βββββββββββ΄ββββββββ βββββββββββ΄ββββββββ βββββββββββ΄ββββββββ β PostgreSQL β β Redis β β AI Services β β (Documents) β β (Cache) β β (OCR/NLP/ML) β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ ```
- Docker and Docker Compose
- Node.js 18+ (for development)
- Google Cloud API credentials
-
Clone the repository: ```bash git clone cd kmrl-document-assistant ```
-
Create environment file: ```bash cp .env.example .env ```
-
Configure environment variables: ```env
DATABASE_URL=postgresql://kmrl_user:kmrl_password@localhost:5432/kmrl_documents
REDIS_URL=redis://localhost:6379
NEXTAUTH_SECRET=your-super-secret-key-here NEXTAUTH_URL=http://localhost:3000
GOOGLE_VISION_API_KEY=your-google-vision-api-key GOOGLE_TRANSLATE_API_KEY=your-google-translate-api-key
WHATSAPP_API_KEY=your-whatsapp-business-api-key SHAREPOINT_CLIENT_ID=your-sharepoint-client-id SHAREPOINT_CLIENT_SECRET=your-sharepoint-client-secret ```
```bash
docker-compose up -d
docker-compose ps
docker-compose logs -f web ```
```bash
npm install
npm run db:migrate
npm run db:seed
npm run dev ```
The mobile app is built as a Progressive Web App (PWA) that can be installed on mobile devices:
- Access the app: Navigate to
https://your-domain.com/mobile - Install PWA: Use browser's "Add to Home Screen" option
- Camera permissions: Grant camera access for document capture
- Offline sync: Documents are cached locally and sync when online
The system uses PostgreSQL with the following main tables:
users- User accounts and rolesdocuments- Document metadata and contentdepartments- Organizational structuredocument_routes- Routing and approval workflowsaudit_logs- Complete activity trackingknowledge_graph- Document relationships
POST /api/documents- Upload documentGET /api/documents- List documents with filtersGET /api/documents/[id]- Get document detailsPUT /api/documents/[id]- Update documentDELETE /api/documents/[id]- Delete document
POST /api/ai/ocr- Extract text from imagesPOST /api/ai/summarize- Generate document summaryPOST /api/ai/translate- Translate text ENβMLPOST /api/ai/classify- Auto-categorize documentsPOST /api/ai/chat- AI chatbot queriesPOST /api/ai/voice- Voice query processing
GET /api/analytics- Dashboard metricsGET /api/ai/knowledge-graph- Graph data
The system supports multiple user roles:
- Admin: Full system access, user management
- Manager: Department oversight, approval workflows
- Employee: Document upload, view assigned documents
- Viewer: Read-only access to public documents
```css /* Primary Colors / --primary: #1e40af; / KMRL Blue */ --primary-foreground: #ffffff;
/* Secondary Colors / --secondary: #f1f5f9; / Light Gray */ --secondary-foreground: #0f172a;
/* Accent Colors / --accent: #059669; / Success Green / --destructive: #dc2626; / Error Red / --warning: #d97706; / Warning Orange */
/* Neutral Colors */ --background: #ffffff; --foreground: #0f172a; --muted: #f8fafc; --muted-foreground: #64748b; --border: #e2e8f0; ```
- Headings: Inter (weights: 400, 500, 600, 700)
- Body: Inter (weights: 400, 500)
- Monospace: JetBrains Mono
- Layout: DashboardLayout, MobileLayout
- Navigation: DashboardSidebar, DashboardHeader
- Documents: DocumentCard, DocumentUpload, DocumentViewer
- AI: AIChatWidget, VoiceRecorder
- Analytics: AnalyticsDashboard, KnowledgeGraph
- UI: Button, Card, Input, Select, Badge, Progress
- JWT-based authentication with NextAuth.js
- Role-based access control (RBAC)
- Session management with Redis
- API route protection
- All API endpoints require authentication
- Input validation and sanitization
- SQL injection prevention with parameterized queries
- XSS protection with Content Security Policy
- HTTPS enforcement in production
- Complete audit trail for all document operations
- Immutable log entries with timestamps
- Data retention policies
- GDPR compliance features
- Health check endpoints
- Performance metrics
- Error tracking and alerting
- Database query monitoring
All user actions are logged with:
- User ID and role
- Action type and timestamp
- Resource affected
- IP address and user agent
- Success/failure status
Complete stack deployment with all services: ```bash docker-compose up -d ```
For production scale deployment: ```bash kubectl apply -f k8s/ ```
For frontend-only deployment: ```bash vercel deploy ```
```bash npm run test ```
```bash npm run test:integration ```
```bash npm run test:e2e ```
- Image optimization with Next.js
- Code splitting and lazy loading
- Redis caching for API responses
- Database query optimization
- CDN integration for static assets
- Core Web Vitals tracking
- API response time monitoring
- Database performance metrics
- Error rate tracking
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For technical support or questions:
- Create an issue in the repository
- Contact the development team
- Check the documentation wiki
- β Core document management
- β Bilingual OCR and translation
- β Web dashboard and mobile PWA
- β Basic AI features
- Advanced workflow automation
- Integration with KMRL systems
- Enhanced mobile app features
- Advanced analytics and reporting
- Machine learning model training
- Advanced document understanding
- Predictive analytics
- IoT device integration ```