This project implements a Risk Model Management system for fraud detection using MongoDB as the database. The implementation showcases key advantages of MongoDB over traditional SQL databases, particularly:
- Schema Flexibility: Add custom risk factors without schema migrations
- Real-Time Updates: Use Change Streams for instant notifications
- Document Model: Natural data representation with embedded risk factors
- Versioning: Complete model versions stored as separate documents
/backend/routes/model_management.py: API endpoints for model CRUD operations/backend/services/risk_model_service.py: Service for managing risk models and Change Streams/backend/dependencies.py: MongoDB connection and service initialization
/frontend/components/ModelAdminPanel.js: UI component for model management with real-time updates
- Dynamic Risk Factors: Add new risk factors on-the-fly without schema migrations
- Real-Time Model Updates: WebSocket + Change Streams for instant notifications
- Complete Document Model: All model data in a single document without JOINs
- Versioned Models: Automatic versioning with full model history using MongoDB sort capabilities to ensure proper version sequencing
- Performance Tracking: Risk factor distribution and effectiveness metrics
GET /models/: List all risk modelsGET /models/{model_id}: Get a specific risk modelPOST /models/: Create a new risk modelPUT /models/{model_id}: Update an existing modelDELETE /models/{model_id}: Archive a risk modelPOST /models/{model_id}/activate: Activate a specific modelGET /models/{model_id}/performance: Get performance metricsPOST /models/{model_id}/feedback: Record transaction outcome feedbackWebSocket /models/change-stream: Real-time model updates via Change Streams
For detailed demo instructions, see RISK_MODEL_MANAGEMENT_IMPLEMENTATION.md
- Model Selection: View and select different risk models
- Schema Flexibility: Add a custom risk factor without schema migrations
- Real-Time Updates: See changes instantly across multiple sessions
- Document Model: Examine the complete model structure
- Version Management: Create a new version and activate models
- Performance Metrics: View risk factor distribution and effectiveness
- Add new fields without migrations vs. SQL ALTER TABLE operations
- Real-time updates via Change Streams vs. SQL polling or triggers
- Natural document structure vs. SQL table joins
- Simple versioning with complete documents vs. SQL change tracking
- MongoDB Atlas cluster (M0 or higher)
- Python 3.9+ with FastAPI and Motor/PyMongo
- Node.js with React for the frontend
- WebSockets enabled (install
websocketslibrary if needed)
- Install dependencies:
poetry install(backend) andnpm install(frontend) - Configure MongoDB connection in
.env - Start backend:
poetry run uvicorn main:app --reload - Start frontend:
npm run dev - Navigate to Risk Model Management page in the application
For detailed implementation information, see RISK_MODEL_MANAGEMENT_IMPLEMENTATION.md
- Fraud Backend README -- Full fraud backend documentation
- Vector Search Implementation -- Vector search deep-dive
- Solution Architecture -- System architecture diagrams
- Data Model -- MongoDB collections and indexes