A distributed application for intelligent document analysis using AI-powered insights across Insurance, Legal, HR, and Compliance domains.
This is a monorepo containing both frontend and backend applications:
policy-brain/
├── frontend/ # Next.js React application
│ ├── app/ # Next.js app router pages
│ ├── components/ # Reusable React components
│ ├── lib/ # Client-side utilities and API calls
│ ├── public/ # Static assets
│ └── package.json # Frontend dependencies
├── backend/ # Node.js Express API server
│ ├── src/ # TypeScript source code
│ ├── dist/ # Compiled JavaScript
│ ├── uploads/ # File upload directory
│ └── package.json # Backend dependencies
└── package.json # Monorepo root with shared scripts
- Multi-Format Document Support: Upload and process PDF, DOCX, and TXT files
- AI-Powered Analysis: Intelligent document analysis with semantic search
- Vector Embeddings: Local sentence-transformer embeddings for document chunks
- LLM Integration: Groq Cloud LLaMA 3 for contextual answer generation
- Vector Database: Pinecone for efficient similarity search
- Domain-Specific Intelligence: Tailored for Insurance, Legal, HR, and Compliance
- Node.js 18+
- npm or yarn
- Pinecone account and API key
- Groq Cloud API key
-
Clone and install dependencies:
git clone <repository-url> cd policy-brain npm install npm run install:all
-
Set up environment variables:
Backend (.env):
# Environment Configuration NODE_ENV=development PORT=5001 # Pinecone Configuration PINECONE_API_KEY=your_pinecone_api_key PINECONE_INDEX_NAME=policy-brain-index PINECONE_ENVIRONMENT=us-east-1 # Groq Configuration GROQ_API_KEY=your_groq_api_key GROQ_MODEL=llama3-8b-8192 # File Upload Configuration MAX_FILE_SIZE=10485760 UPLOAD_DIR=uploads # Embedding Configuration CHUNK_SIZE=1000 CHUNK_OVERLAP=200
Frontend (.env.local):
NEXT_PUBLIC_BACKEND_URL=http://localhost:5001
npm run devThis will start both frontend (http://localhost:3000) and backend (http://localhost:5001) concurrently.
Frontend only:
npm run dev:frontend
# or
cd frontend && npm run devBackend only:
npm run dev:backend
# or
cd backend && npm run dev- Health Check:
GET /health - Upload Document:
POST /api/upload - Query Documents:
POST /api/query - List Documents:
GET /api/documents
# Build both services
npm run build
# Start production servers
npm run start- Next.js 15 - React framework with App Router
- React 19 - UI library
- TypeScript - Type safety
- Tailwind CSS - Styling
- Lucide React - Icons
- Node.js - Runtime
- Express.js - Web framework
- TypeScript - Type safety
- Pinecone - Vector database
- Groq Cloud - LLM API
- Xenova Transformers - Local embeddings
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
MIT License - see LICENSE file for details.
Backend (.env):
PINECONE_API_KEY=your_pinecone_api_key
GROQ_API_KEY=your_groq_api_key
PINECONE_INDEX_NAME=policy-brain-index
PINECONE_ENVIRONMENT=us-east-1Frontend (.env.local):
NEXT_PUBLIC_BACKEND_URL=http://localhost:5001npm run devThis will start:
- Frontend: http://localhost:3005
- Backend: http://localhost:5001
Frontend only:
npm run dev:frontendBackend only:
npm run dev:backendPOST /api/upload
Content-Type: multipart/form-dataUpload documents for processing and embedding.
POST /api/query
Content-Type: application/jsonQuery documents with natural language questions.
GET /api/statusGet system health and statistics.
npm run buildcd frontend
npm run build
npm run startcd backend
npm run build
npm run start- Framework: Next.js 15 with App Router
- Language: TypeScript
- Styling: Tailwind CSS
- Icons: Lucide React
- Runtime: Node.js with Express.js
- Language: TypeScript
- AI/ML: Groq SDK, @xenova/transformers
- Database: Pinecone Vector Database
- File Processing: pdf-parse, mammoth
- Security: Helmet, CORS
- Install dependencies:
npm run install:all - Start development:
npm run dev - Make changes to frontend/ or backend/
- Test both services work together
- Submit pull request
This project is licensed under the MIT License.