B12 is a comprehensive, enterprise-grade text analysis platform that combines advanced Natural Language Processing (NLP) capabilities with a modern web interface. It provides end-to-end document processing, analysis, and insights through a scalable REST API powered by machine learning and LLM integration.
The platform demonstrates a complete pipeline from raw document ingestion through sophisticated AI-powered analytics, utilizing state-of-the-art libraries and APIs for production-ready text intelligence.
- ๐ Multi-Format Document Parsing: Support for PDF, DOCX, PPTX, HTML, and image formats with layout preservation
- ๐ Intelligent Text Analysis: Document summarization, sentiment analysis, and topic modeling
- ๐ง Advanced Topic Modeling: BERTopic-powered unsupervised topic discovery with LLM-enhanced labeling
- ๐ Interactive Visualizations: Comprehensive charts, word clouds, and trend analysis for insights
- ๐ RESTful API: FastAPI backend with comprehensive endpoints for all analysis tasks
- ๐ป Modern Web Interface: React-based frontend for document processing and results visualization
- โก Concurrent Processing: Batch processing capabilities for large-scale text analysis
- ๐ LLM Integration: OpenRouter API integration for enhanced summarization and analysis
- Framework: FastAPI with async support
- Document Processing: PyMuPDF, python-docx, Docling
- Text Analysis: NLTK, Sentence Transformers
- Machine Learning: BERTopic, UMAP, HDBSCAN
- LLM Integration: OpenRouter API
- Deployment: Uvicorn
- Framework: React 19
- Language: TypeScript
- Build Tool: Vite
- Charting: Recharts for interactive visualizations
- PDF Export: jsPDF, react-to-pdf
- Markdown Rendering: react-markdown
- Python 3.9+
- Node.js 16+
- Virtual environment (venv)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Frontend (React + TypeScript) โ
โ - Document Upload & Processing โ
โ - Results Visualization โ
โ - PDF Export Functionality โ
โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP/REST
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Backend (FastAPI) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Analysis Routers โ โ
โ โ - Topic Modeling โ โ
โ โ - Sentiment Analysis โ โ
โ โ - Document Summarization โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ NLP Services & Pipelines โ โ
โ โ - Async Task Processing โ โ
โ โ - Model Inference โ โ
โ โ - Data Extraction โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ML/Data Layer โ
โ - BERTopic Models โ
โ - Pretrained Transformers โ
โ - External LLM APIs โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Python 3.9 or higher
- Node.js 16 or higher
- pip and npm package managers
git clone <repository-url>
cd B12---The-Dynamic-text-analysis-Platform# Create and activate virtual environment
python -m venv .venv
.venv\Scripts\activate # On Windows
# source .venv/bin/activate # On macOS/Linux
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
# Create .env file in backend directory with necessary API keyscd frontend
# Install dependencies
npm install
# Build TypeScript
npm run buildcd backend
uvicorn main:app --reload
# API will be available at http://localhost:8000
# Interactive API docs at http://localhost:8000/docscd frontend
npm run dev
# Application will be available at http://localhost:5173# Frontend
cd frontend
npm run build
# Backend is ready for deployment with any ASGI serverhttp://localhost:8000
GET /healthPOST /predict # Predict topics for input text
GET /model-info # Get model metadata
DELETE /reset-session # Reset analysis sessionPOST /sentiment # Analyze sentiment in documentsPOST /summarize # Generate document summariesFull API documentation available at /docs when backend is running.
B12---The-Dynamic-text-analysis-Platform/
โโโ backend/ # FastAPI application
โ โโโ main.py # Application entry point
โ โโโ core/
โ โ โโโ config.py # Configuration management
โ โโโ models/
โ โ โโโ schemas.py # Data models & validation
โ โโโ routers/
โ โ โโโ topic.py # Topic modeling endpoints
โ โ โโโ sentiment.py # Sentiment analysis endpoints
โ โ โโโ summarize.py # Summarization endpoints
โ โโโ services/
โ โโโ async_tasks.py # Async task processing
โ โโโ extractor.py # Text extraction utilities
โ โโโ pipelines.py # ML inference pipelines
โโโ frontend/ # React application
โ โโโ src/
โ โ โโโ App.tsx # Main component
โ โ โโโ main.tsx # Entry point
โ โ โโโ types.ts # TypeScript types
โ โ โโโ assets/ # Static assets
โ โโโ index.html # HTML template
โ โโโ package.json # Frontend dependencies
โ โโโ vite.config.ts # Vite configuration
โ โโโ tsconfig.json # TypeScript configuration
โโโ task1/ # Parser Evaluation & Research
โ โโโ task1_eval.py # Library comparison script
โ โโโ Task1_Parser_Evaluation.md # Evaluation report
โโโ task2/ # Basic Parser Implementation
โ โโโ pymupdf_parser.py # PDF/DOCX extraction
โโโ task3/ # Advanced Parser
โ โโโ doc_parser.py # Multi-format parsing with Docling
โโโ task4/ # Text Preprocessing
โ โโโ preprocessing.py # Tokenization, stemming, lemmatization
โ โโโ step_by_step_demo.py # Pipeline demonstration
โโโ task5/ # Document Summarization
โ โโโ summarizer_openrouter.py # LLM-based summarization
โโโ task6/ # Sentiment Analysis
โ โโโ sentiment_analyzer.py # Multi-batch sentiment processing
โโโ task7/ # Topic Modeling
โ โโโ train_topic_model.py # BERTopic model training
โ โโโ run_inference.py # Topic inference
โ โโโ models/ # Trained model artifacts
โ โโโ results/ # Classification results
โโโ task8/ # Legacy API Implementation
โ โโโ api.py # Original FastAPI setup
โโโ processed_data/ # Sample outputs
โโโ assets/ # Input documents
โโโ LICENSE
โโโ README.md # This file
Raw Documents (PDF, DOCX, PPTX, etc.)
โ
Document Parsing (Task 3)
[Docling + PyMuPDF Fallback]
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ โ
Raw, Formatted Text [Archived / Standalone Utility]
(Maintains natural grammar) Text Preprocessing (Task 4)
โ (Not used in current pipeline)
โ
โโโโโโโโโผโโโโโโโโโโโโโโโ
โ โ โ
Task 5 Task 6 Task 7
(Summ.) (Sent.) (Topic)
[LLM] [FinBERT] [BERTopic]
โ โ โ
โโโโโโโโโผโโโโโโโโโโโโโโโ
โ
REST API (FastAPI Backend)
โ
Web Interface (React Frontend)
โ
Results, Dashboards & Insights
- Multi-format support: PDF, DOCX, PPTX, HTML, XML, images
- Layout preservation: Maintains document structure in Markdown output
- Batch processing: Handle multiple documents concurrently
- Format evaluation: Comparative analysis of parsing libraries with WER metrics
- Word Clouds: Visual representation of key themes and keywords
- Topic Distribution Charts: Bar charts showing all discovered topics with confidence scores
- Sentiment Distribution: Pie charts for positive/negative/neutral sentiment breakdowns
- Sentiment Trend Analysis: Scatter plots showing sentiment evolution through the document
- Custom Tooltips: Interactive hover information for detailed insights
- PDF Export: All visualizations included in exported reports
- Sentiment Analysis: LLM-powered sentiment detection with concurrent processing
- Document Summarization: Extract key information using advanced LLMs (Gemini, Llama)
- Topic Modeling: Unsupervised topic discovery with semantic understanding
- Text Preprocessing: Advanced NLP preprocessing pipeline
- Modular design: Each analysis component is independently deployable
- Async-first: Built for high-throughput concurrent processing
- LLM integration: Seamless integration with external AI APIs
- RESTful endpoints: Standard HTTP API for all functionality
# Example: Run document parser
python task3/doc_parser.py
# Example: Run preprocessing demo
python task4/step_by_step_demo.py
# Example: Run sentiment analysis
python task6/sentiment_analyzer.py
# Example: Train topic model
python task7/train_topic_model.pycd frontend
npm run lint # Run ESLint
npm run build # Verify TypeScript compilationBackend requires the following environment variables (.env file):
OPENROUTER_API_KEY=your_api_key_here
DATABASE_URL=optional_database_url
LOG_LEVEL=INFO
# Install production server
pip install gunicorn
# Run with multiple workers
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000# Build for production
npm run build
# Serve with your preferred web server (nginx, Apache, etc.)
# Outputs to: frontend/dist/Create Dockerfile for backend:
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]- Backend: Consider using Redis for caching model predictions
- Frontend: Implement lazy loading for large document uploads
- Database: Monitor query performance with appropriate indexing
- API: Implement rate limiting for production use
Issue: Backend fails to start with model loading errors
# Solution: Ensure all model dependencies are installed
pip install -r requirements.txt
python -c "import torch; import transformers; print('Dependencies OK')"Issue: Frontend cannot connect to backend API
# Solution: Check backend is running and CORS is properly configured
# Verify Backend is running on http://localhost:8000
# Check frontend environment configurationIssue: Out of memory errors during topic modeling
# Solution: Reduce batch size in task7/train_topic_model.py
# or use GPU acceleration if availableIssue: API returns 500 errors during document processing
# Solution: Check backend logs and ensure OpenRouter API key is valid
# Verify input documents are in supported formats- Document Parsing: ~50-100 KB/s depending on format complexity
- Text Preprocessing: ~10,000 tokens/second
- Topic Modeling Inference: <1s per document
- API Response Time: <500ms for single document analysis
{
"topics": [
{
"id": 0,
"label": "Finance",
"probability": 0.95
},
{
"id": 1,
"label": "Technology",
"probability": 0.03
}
],
"processing_time_ms": 245
}{
"sentiment": "positive",
"confidence": 0.92,
"entities": ["company", "growth", "innovation"],
"summary": "Document discusses positive business developments"
}{
"original_length": 2500,
"summary_length": 450,
"summary": "Key points about the document...",
"key_phrases": ["metric1", "metric2", "metric3"]
}The project includes comprehensive research documentation:
- Parser Evaluation (Task 1): Comparative analysis of PDF parsing libraries
- Preprocessing Techniques (Task 4): Detailed results and comparisons
- Model Performance (Task 7): Topic modeling accuracy and metrics
See individual task directories for detailed reports and evaluation results.
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Python: Follow PEP 8 guidelines
- TypeScript: Use provided ESLint configuration
- Documentation: Update README and add docstrings for new functions
- Testing: Include test cases for new features
This project is licensed under the MIT License - see the LICENSE file for details.
- BERTopic: Advanced topic modeling framework
- Sentence Transformers: Semantic embeddings
- OpenRouter: LLM API aggregation
- FastAPI: Modern web framework
- React: UI framework
- Phase 1: Document parsing and evaluation
- Phase 2: Text preprocessing pipeline
- Phase 3: Advanced analysis modules (summarization, sentiment)
- Phase 4: Topic modeling integration
- Phase 5: API deployment and backend integration
- Phase 6: Frontend development and visualization
- Multi-language support
- Advanced visualization dashboard
- Real-time collaborative analysis
- Model fine-tuning interface
- GraphDB integration for entity relationships
- Knowledge graph extraction
- Advanced search capabilities
- Batch processing optimization
- Distributed processing support
- Custom model training UI
- Advanced reporting and analytics
- Enterprise integrations
For issues, feature requests, or questions:
- Issues: Use GitHub Issues tracker
- Documentation: See task-specific markdown files
- API Docs: Visit
http://localhost:8000/docswhen running backend
Last Updated: March 2026 Maintainer: B12 Development Team Status: Active Development