How aspirant200715/diffucat works
Purpose and Entry Points
DiffuCat is a catalyst-discovery platform: users submit molecular SMILES, obtain ML property predictions and uncertainty/rank signals, inspect candidates in 3D, and submit selected molecules to a lab/validation workflow. The runnable backend entry point is src/backend/main.py; the Next.js UI enters through frontend/app/layout.tsx and frontend/app/page.tsx. Deployment is split between a browser frontend and FastAPI inference service.
Frontend Application Shell
Next.js provides the research UI, with shared main-area navigation/layout and route-level screens for dashboard, molecule archive/detail, lab console, authentication, and settings.
• frontend/app/(main)/layout.tsx
• frontend/app/(main)/dashboard/page.tsx
• frontend/app/(main)/lab/page.tsx
The frontend boundary is a typed API client plus local discovery state; UI components should not directly own backend protocol concerns.
• frontend/lib/api.ts
• frontend/lib/types.ts
• frontend/store/discovery.ts
Discovery and Visualization Flow
Dashboard input accepts molecules, sends them to inference endpoints, and renders prediction tables/grids, Pareto/UCB indicators, uncertainty, and molecular views. This is the principal user-facing flow from SMILES to interpretable candidate assessment.
• frontend/components/discovery/MoleculeInput.tsx
• frontend/components/discovery/PredictionResultsGrid.tsx
• frontend/components/visualization/Molecule3DViewer.tsx
3D visualization uses 3Dmol.js per the README and is a presentation boundary: it consumes structural/prediction data rather than performing chemistry inference.
FastAPI API and Orchestration
The backend exposes versioned routes for generation, prediction, ranking, and laboratory operations. main.py is the HTTP composition root; route modules define externally visible service boundaries. A pipeline service coordinates multi-step inference work behind these routes.
• src/backend/main.py
• src/backend/api/v1/predict.py
• src/backend/services/pipeline.py
Additional API domains:
• src/backend/api/v1/generate.py
• src/backend/api/v1/rank.py
• src/backend/api/v1/lab.py
ML, Data, and Candidate Selection
The scientific core separates molecular data preparation, learned models, training, and decision services. Data loaders/processors transform source molecular records into model-ready representations; diffusion and predictor models support generation/inference; ranking and active learning select valuable candidates under predicted performance and uncertainty.
• src/data/processor.py
• src/models/diffusion.py
• src/models/predictor.py
• src/services/ranking.py
• src/services/active_learning.py
• src/training/trainer.py
Asynchronous and External Execution
Celery supports asynchronous prediction work, configured separately from HTTP handling. The lab service is an integration boundary for virtual or automated laboratory submission/status. WebSockets support live visualization/event delivery to clients.
• src/backend/core/celery_app.py
• src/backend/tasks/predict_tasks.py
• src/backend/services/lab_client.py
• src/backend/websockets/visualization.py
Validation is pluggable: a manager selects mock, local ORCA, or cloud-API engines, isolating computational chemistry/vendor execution from the ML/API layer.
• src/validation/manager.py
• src/validation/engines/orca.py
• src/validation/engines/cloud_api.py
Runtime, Reproducibility, and Outputs
Material runtimes are Python 3.9+ / FastAPI / GNN stack and Node.js 18+ / Next.js; Docker Compose packages services for local deployment. DVC tracks research data/pipeline artifacts, while result JSON files hold demo and DFT-validation outputs.
• docker/Dockerfile
• docker/docker-compose.yml
• dvc.yaml
• configs/backend.yaml
• results/dft_validation.json
• results/dft/CCO.json
Main entry points: main.py HTTP composition root · pipeline.py Inference pipeline · manager.py Validation manager · processor.py Molecular preparation
Components 24
Next.js Frontend
- App shell & routes · Dashboard, lab, archive, auth, and settings screens.
frontend/app/(main)/layout.tsx - Discovery UI · Accepts SMILES and presents candidate predictions.
frontend/components/discovery/MoleculeInput.tsx - Typed API client · Keeps backend protocol concerns outside UI components.
frontend/lib/api.ts - Discovery state
frontend/store/discovery.ts - 3D molecule viewer · Renders structural and prediction data without chemistry inference.
frontend/components/visualization/Molecule3DViewer.tsx
FastAPI Service
- HTTP composition root · Composes versioned API domains.
src/backend/main.py - Prediction API · External inference boundary.
src/backend/api/v1/predict.py - Generation & ranking APIs
src/backend/api/v1/generate.py - Lab API
src/backend/api/v1/lab.py - Inference pipeline · Coordinates multi-step molecular inference.
src/backend/services/pipeline.py - Live visualization events
src/backend/websockets/visualization.py
Scientific Core
- Molecular preparation · Transforms molecular records into model-ready representations.
src/data/processor.py - Diffusion & predictor models · Generate molecules and predict properties with uncertainty.
src/models/diffusion.py - Ranking & active learning · Selects candidates by performance and uncertainty.
src/services/ranking.py - Model training
src/training/trainer.py
Async & Validation
- Celery worker runtime · Separates prediction jobs from HTTP handling.
src/backend/core/celery_app.py - Async prediction tasks
src/backend/tasks/predict_tasks.py - Laboratory integration · Submits molecules and obtains laboratory status.
src/backend/services/lab_client.py - Validation manager · Selects mock, local ORCA, or cloud validation engines.
src/validation/manager.py - ORCA validation engine
src/validation/engines/orca.py - Cloud validation engine
src/validation/engines/cloud_api.py
Other components
- Validation outputs · Stores demo and DFT validation outcomes.
results/dft_validation.json - DVC pipeline · Tracks research data and pipeline artifacts.
dvc.yaml - Container deployment · Packages frontend and inference service for local deployment.
docker/docker-compose.yml
Connections 28
- App shell & routes → Discovery UI: hosts
- Discovery UI → Typed API client: submits SMILES
- Typed API client → HTTP composition root: HTTP API
- Discovery UI → Discovery state: updates
- Discovery state → 3D molecule viewer: provides structures
- HTTP composition root → Prediction API: mounts
- HTTP composition root → Generation & ranking APIs: mounts
- HTTP composition root → Lab API: mounts
- HTTP composition root → Live visualization events: serves
- Prediction API → Inference pipeline: invokes
- Generation & ranking APIs → Inference pipeline: invokes
- Inference pipeline → Molecular preparation: prepares inputs
- Molecular preparation → Diffusion & predictor models: model-ready data
- Inference pipeline → Diffusion & predictor models: runs inference
- Inference pipeline → Ranking & active learning: scores candidates
- Prediction API → Async prediction tasks: queues work
- Async prediction tasks → Celery worker runtime: executes on
- Async prediction tasks → Inference pipeline: runs pipeline
- Lab API → Laboratory integration: submits to lab
- Laboratory integration → Validation manager: requests validation
- Validation manager → ORCA validation engine: local engine
- Validation manager → Cloud validation engine: cloud engine
- Validation manager → Validation outputs: writes outputs
- Molecular preparation → Model training: training data
- Model training → Diffusion & predictor models: trains
- DVC pipeline → Molecular preparation: tracks artifacts
- Container deployment → App shell & routes: packages
- Container deployment → HTTP composition root: packages