Architecture and Components - acelot-inc/boltzmann GitHub Wiki
app.py
boltzmann/boltz.py
boltzmann/models.py
boltzmann/web/apiv1.py
Related topics: Installation and Setup, API Reference, Database Models
This document outlines the architecture and key components of the Boltzmann project, focusing on the interaction between its core files.
The Boltzmann project is structured around four primary files: app.py
, boltzmann/boltz.py
, boltzmann/models.py
, and boltzmann/web/apiv1.py
. Each file plays a specific role in the application's functionality, from handling API requests to managing data models and executing core logic.
app.py
serves as the entry point for the Boltzmann application. It initializes the Flask application, configures the database connection, and registers the API blueprint.
Purpose and Functionality:
- Flask app initialization
- Database configuration
- API blueprint registration
Code Snippet:
from flask import Flask
from boltzmann.web.apiv1 import bp as apiv1_bp
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///boltzmann.db'
app.register_blueprint(apiv1_bp, url_prefix='/api/v1')
if __name__ == '__main__':
app.run(debug=True)
Integration:
app.py
acts as the central coordinator, bringing together the other components by initializing Flask and registering the API blueprint, which makes the API endpoints accessible.
Sources: SOURCE_DISPLAY
This file contains the core business logic for the Boltzmann application, including functions for docking, scoring, and simulation management.
Purpose and Functionality:
- Docking ligands to proteins
- Implementing scoring algorithms
- Managing the simulation queue
Code Snippet:
# Example (Hypothetical) - Actual implementation may vary
def dock_ligand(ligand, protein):
# Docking logic here
pass
def score_docking(docking_result):
# Scoring logic here
pass
Integration:
boltzmann/boltz.py
provides the functions that the API endpoints call to perform docking and scoring. It is a critical part of the backend processing.
Sources: SOURCE_DISPLAY
This file defines the data models used in the Boltzmann application using SQLAlchemy. These models represent the database tables and their relationships.
Purpose and Functionality:
- Defining classes for
Session
,Protein
, andLigand
- Setting up relationships between models
- Providing a structured way to interact with the database
Code Snippet:
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Session(db.Model):
id = db.Column(db.Integer, primary_key=True)
# ... other columns
class Protein(db.Model):
id = db.Column(db.Integer, primary_key=True)
# ... other columns
class Ligand(db.Model):
id = db.Column(db.Integer, primary_key=True)
# ... other columns
Integration:
boltzmann/models.py
defines the structure of the data stored and retrieved by the application. The API endpoints use these models to interact with the database.
Sources: SOURCE_DISPLAY
This file defines the API endpoints for the Boltzmann application using Flask blueprints, handling incoming requests and returning data in JSON format.
Purpose and Functionality:
- Defining routes for creating sessions, adding ligands, and retrieving results
- Handling request parsing and validation
- Serializing data into JSON format for responses
Code Snippet:
from flask import Blueprint, request, jsonify
bp = Blueprint('apiv1', __name__)
@bp.route('/enqueue/<session_id>', methods=['POST'])
def enqueue(session_id):
# Process the request and return a JSON response
return jsonify({'message': 'Job enqueued'}) # Example response
Integration:
boltzmann/web/apiv1.py
acts as the interface between the front-end and the back-end logic. It receives requests, calls functions from boltzmann/boltz.py
, and returns results.
Sources: SOURCE_DISPLAY
The following diagram illustrates the sequence of interactions between the key components of the Boltzmann application during a typical request.
sequenceDiagram
participant User
participant API
participant CoreLogic
participant Database
User->>API: Enqueue Request
activate API
API->>CoreLogic: Call Docking Function
activate CoreLogic
CoreLogic->>Database: Retrieve Data Models
activate Database
Database-->>CoreLogic: Data Models
deactivate Database
CoreLogic->>Database: Store Results
activate Database
Database-->>CoreLogic: Confirmation
deactivate Database
CoreLogic-->>API: Results
deactivate CoreLogic
API-->>User: JSON Response
deactivate API