A complete end-to-end document intelligence platform with:
✅ FastAPI Application with structured logging and Prometheus metrics
✅ Pydantic v2 Models for request/response validation
✅ Async SQLAlchemy database integration with PostgreSQL
✅ Health Check & Monitoring endpoints
✅ Docker & Docker Compose setup
✅ Environment-based Configuration
✅ Global Exception Handling and CORS middleware
GET /health- Health check with version infoGET /metrics- Prometheus metrics for monitoringPOST /ingest- Document ingestion (async job creation)POST /query- RAG-based document queryingGET /docs- Interactive API documentation
- FastAPI - Modern, fast web framework
- PostgreSQL + pgvector - Vector database for embeddings
- Redis - Message queue and caching
- Celery - Async task processing
- Prometheus + Grafana - Monitoring and visualization
python test_setup.py# Start all services
docker-compose up -d
# Check status
docker-compose ps
# View logs
docker-compose logs -f app# Install dependencies
pip install -r requirements.txt
# Set up environment
cp env.example .env
# Start the application
python run.pycurl http://localhost:8000/healthcurl http://localhost:8000/metricscurl -X POST http://localhost:8000/ingest \
-H "Content-Type: application/json" \
-d '{
"file_url": "https://example.com/sample.pdf",
"metadata": {"title": "Sample Doc"},
"chunk_size": 800
}'curl -X POST http://localhost:8000/query \
-H "Content-Type: application/json" \
-d '{
"query": "What is the main topic?",
"top_k": 5
}'python demo.pyKey environment variables in .env:
| Variable | Purpose | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection | postgresql+asyncpg://user:password@localhost/knowledgeops |
REDIS_URL |
Redis connection | redis://localhost:6379/0 |
OPENAI_API_KEY |
LLM API key | None |
DEBUG |
Debug mode | false |
LOG_LEVEL |
Logging level | INFO |
- HTTP Requests: Count and duration by endpoint
- Business Metrics: Ingestion jobs, query requests
- System Metrics: Database connections, document counts
- Access at
http://localhost:3000(admin/admin) - Pre-configured dashboards for application metrics
- Application health:
GET /health - Database connectivity
- External service status
- Document text extraction (PDF, DOC, HTML)
- Text chunking and embedding generation
- Vector database integration
- LLM integration for answer generation
- Authentication and authorization
- Multi-tenant support
- Admin UI
- Advanced query filters
- Performance optimization
- Security hardening
- Backup and recovery
- CI/CD pipeline
knowledgeops-ai/
├── app/ # Main application
│ ├── main.py # FastAPI app
│ ├── config.py # Configuration
│ ├── database.py # Database setup
│ ├── models.py # Pydantic models
│ ├── logging.py # Structured logging
│ └── metrics.py # Prometheus metrics
├── docker-compose.yml # Multi-service setup
├── Dockerfile # Application container
├── requirements.txt # Python dependencies
├── run.py # Startup script
├── demo.py # API demo
└── test_setup.py # Setup verification
# Start development
python run.py
# Run tests
python test_setup.py
# Demo API
python demo.py
# Docker development
docker-compose up -d
docker-compose logs -f
# View API docs
open http://localhost:8000/docsYou now have a production-ready foundation for a document intelligence platform with:
- ✅ Modern FastAPI architecture
- ✅ Structured logging and monitoring
- ✅ Docker containerization
- ✅ Database integration
- ✅ API documentation
- ✅ Health checks and metrics
The platform is ready for implementing the core RAG functionality and can scale to handle real document processing workloads!