An AI-powered document processing API that automatically extracts and summarizes content from PDF and Word documents using advanced language models.
This API provides intelligent document management with automatic text extraction from PDFs and AI-powered summarization. Users can upload documents, extract text content, and generate comprehensive summaries highlighting key points, main arguments, and actionable insights.
- Document Upload & Processing - Support for PDF, DOC, and DOCX files (up to 5MB)
- AI-Powered Summarization - Structured summaries using OpenRouter AI (Mistral DevStral model)
- Secure Storage - Documents stored in MinIO, metadata in MongoDB
- User Authentication - JWT-based authentication with bcrypt password hashing
- Batch Operations - Bulk document deletion support
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose ODM
- Storage: MinIO object storage
- AI: OpenRouter API (Mistral DevStral)
- File Processing: pdf2json, multer
- Auth: JWT, bcrypt
- Other: Axios, UUID
Node.js 16+
MongoDB 9+
MinIO Server
OpenRouter API Key- Clone and install dependencies
git clone <repository-url>
cd document-summarizer
npm install- Configure environment
Create .env.development.local:
PORT=3000
DB_URI=mongodb://localhost:27017/document-summarizer
JWT_SECRET=your-super-secure-secret-minimum-32-chars
JWT_EXPIRES_IN=7d
MINIO_ENDPOINT=localhost
MINIO_PORT=9000
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
OPENROUTER_API_KEY=your-openrouter-api-key- Setup MinIO
- Start MinIO server
- Access console at http://localhost:9000
- Create bucket named
document-summarizer
- Run the application
npm run start:dev # Development mode
npm start # Production modeBase URL: http://localhost:3000/api/v1
Authentication: Include JWT token in header: Authorization: Bearer <token>
POST /auth/signup
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123"
}POST /auth/signin
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123"
}Response includes token for authenticated requests.
POST /document/upload
Authorization: Bearer <token>
Content-Type: multipart/form-data
document: <file>Supports: PDF, DOC, DOCX (max 5MB)
GET /document/all
Authorization: Bearer <token>GET /document/:id
Authorization: Bearer <token>POST /document/:id/analyse
Authorization: Bearer <token>Sends extracted text to AI and returns structured summary.
DELETE /document/:id
Authorization: Bearer <token>POST /document/delete-multiple
Authorization: Bearer <token>
Content-Type: application/json
{
"documentIds": ["id1", "id2", "id3"]
}{
_id: UUID,
email: String (unique, validated),
password: String (bcrypt hashed),
createdAt: Date,
updatedAt: Date
}{
_id: ObjectId,
user: UUID (ref: User),
filename: String,
file_type: String ('.pdf', '.doc', '.docx'),
file_size: Number (MB),
status: String ('uploaded', 'processing', 'completed', 'failed'),
raw_text: String,
summary: String,
document_type: String ('invoice', 'cv', 'report', 'letter', 'unknown'),
metadata: Mixed,
createdAt: Date,
updatedAt: Date
}- Password Hashing: bcrypt with 10 salt rounds
- JWT Authentication: Secure token-based auth with configurable expiration
- File Validation: Type, size, and MIME type checking
- Ownership Checks: Users can only access their own documents
- Environment Variables: Sensitive data stored in
.envfiles
document-summarizer/
βββ app.js # Main application entry
βββ config/
β βββ env.js # Environment configuration
β βββ model.js # AI integration (OpenRouter)
β βββ multer.js # File upload configuration
βββ controller/
β βββ auth.controller.js # Authentication logic
β βββ document.controller.js # Document CRUD & processing
βββ database/
β βββ db.js # MongoDB connection
βββ middlewares/
β βββ auth.middleware.js # JWT authentication
β βββ fileValidation.middleware.js # File validation
βββ models/
β βββ user.model.js # User schema
β βββ document.model.js # Document schema
βββ router/
β βββ auth.router.js # Auth routes
β βββ document.router.js # Document routes
βββ package.json
Register:
curl -X POST http://localhost:3000/api/v1/auth/signup \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"test123"}'Login:
curl -X POST http://localhost:3000/api/v1/auth/signin \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"test123"}'Upload Document:
curl -X POST http://localhost:3000/api/v1/document/upload \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "document=@/path/to/file.pdf"Analyze Document:
curl -X POST http://localhost:3000/api/v1/document/DOCUMENT_ID/analyse \
-H "Authorization: Bearer YOUR_TOKEN"Update .env.production.local:
PORT=3000
DB_URI=mongodb+srv://user:pass@cluster.mongodb.net/db
JWT_SECRET=production-secret-min-32-chars
MINIO_ENDPOINT=your-minio-server.com
OPENROUTER_API_KEY=your-api-key- Heroku: Set config vars, deploy via Git
- Railway: Connect GitHub, configure env vars
- DigitalOcean: Use App Platform with environment variables
- AWS/GCP: Deploy with Docker or directly on compute instances
- Strong JWT_SECRET in production
- HTTPS/TLS enabled
- MongoDB authentication enabled
- MinIO access properly secured
- CORS configured appropriately
- Rate limiting implemented
- Regular security updates
Contributions welcome! Please follow these steps:
- 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
This project is open source and available under the MIT License.
- Add support for more file formats (TXT, RTF, etc.)
- Implement DOC/DOCX text extraction
- Add document classification (invoice, CV, report, etc.)
- Email notifications for completed analyses
- Batch upload support
- Search functionality across documents
- Export summaries to PDF/DOCX
- Multi-language support
- Real-time processing status via WebSockets
For questions or support, please open an issue in the repository.
Built with β€οΈ using Node.js, Express, MongoDB, MinIO, and AI