This project is an AI-powered Document Analyzer API built using FastAPI. It processes documents (PDF, DOCX, and images) by extracting text, generating summaries, identifying key entities, and performing sentiment analysis.
The system accepts files in Base64 format, decodes them, extracts content using OCR or parsing techniques, and applies NLP-based analysis to return structured insights.
- Language/Framework: Python, FastAPI
- Key Libraries: Uvicorn, Pydantic, Base64, pytesseract, PIL
- AI/NLP: Basic NLP techniques for summarization and sentiment analysis
The system follows a simple API-based architecture:
Client (Postman / Swagger) ↓ FastAPI Backend (Render) ↓ Document Processing Layer ↓ Text Extraction (PDF/DOCX/OCR) ↓ NLP Analysis (Summary, Entities, Sentiment) ↓ JSON Response
- Clone the repository
git clone https://github.com/prav-tech/document-analyzer-api.git
cd document-analyzer-api- Install dependencies
pip install -r requirements.txt- Set environment variables
Create a
.envfile:
API_KEY=your_secret_key
- Run the application
uvicorn src.main:app --reload- Open in browser:
http://127.0.0.1:8000/docs
-
Input Handling
- Accept document as Base64 string
- Identify file type (PDF, DOCX, Image)
-
File Processing
- Decode Base64 to file
- Save temporarily
-
Text Extraction
- PDFs/DOCX → direct parsing
- Images → OCR using Tesseract
-
Analysis
- Generate summary
- Extract entities (names, dates, organizations, etc.)
- Perform sentiment analysis
-
Output
- Return structured JSON response
Headers:
x-api-key: your_secret_key
Content-Type: application/json
Request Body:
{
"fileName": "sample.pdf",
"fileType": "pdf",
"fileBase64": "BASE64_STRING"
}{
"status": "success",
"fileName": "sample.pdf",
"summary": "Short summary...",
"entities": {
"names": [],
"dates": [],
"organizations": [],
"amounts": [],
"locations": []
},
"sentiment": "Neutral"
}✅ API working ✅ Deployed on Render ✅ Tested using Postman & Swagger
- OCR: Tesseract (for image text extraction)
- NLP: Basic rule-based and text processing techniques
- AI Assistance: ChatGPT (for debugging, guidance, and optimization)
- Entity extraction may not always detect all entities accurately
- Sentiment analysis is basic and may not reflect deep context
- OCR accuracy depends on image quality
- Large files may take longer to process
- No frontend UI (API-based interaction only)
Pravallika B