🛠️ Developer Guide

Everything you need to set up, develop, test, and contribute to BioBots Tool.

Prerequisites

ToolVersionPurpose
Visual Studio2015+C# backend development
.NET Framework4.xRuntime
Node.js18+Running JavaScript tests
npm9+Package management
Git2.xSource control
Docker(optional)Container builds

Setup

1

Clone the repository

git clone https://github.com/sauravbhattacharya001/BioBots.git
cd BioBots
2

Install JavaScript dependencies

npm install

This installs Jest and jsdom for running the frontend test suite.

3

Open the solution in Visual Studio

start BioBotsTool.sln

Visual Studio will restore NuGet packages automatically.

4

Run the backend

Press F5 (debug) or Ctrl+F5 (without debugger) to launch the development server.

Running Locally

Backend (ASP.NET Web API)

The backend runs on IIS Express via Visual Studio. After launching, navigate to the URL shown in the browser (typically http://localhost:{port}/index.html).

Frontend (GitHub Pages Preview)

To preview the docs site locally without the backend, serve the docs/ directory with any static file server:

# Using Python
cd docs
python -m http.server 8080

# Using Node.js (npx)
npx serve docs

# Using PHP
php -S localhost:8080 -t docs

Custom Data File

The backend reads bioprint-data.json from the application root by default. To use a custom path, set DataFilePath in Web.config:

<appSettings>
  <add key="DataFilePath" value="C:\data\my-prints.json" />
</appSettings>
💡 Hot reload: The data file is watched for changes. Edit it while the server is running and the next request will use the updated data automatically — no restart needed.

Testing

Run All Tests

npm test

Runs Jest with verbose output and coverage reporting.

Run with Coverage Report

npm run coverage

Generates HTML, LCOV, and JSON coverage reports in the coverage/ directory. Open coverage/index.html in a browser for an interactive report.

Check Coverage Thresholds

npm run coverage:check

Fails if coverage drops below the configured thresholds (70% lines, 60% branches).

Run Specific Test File

# Run only the runMethod tests
npx jest __tests__/runMethod.test.js --verbose

# Run only the comparison tool tests
npx jest __tests__/compare.test.js --verbose

Watch Mode

npx jest --watch

Re-runs tests automatically when source files change.

Test Structure

FileTestsWhat It Covers
runMethod.test.js ~87 isNumeric(), setButtonsEnabled(), runMethod() — URL construction, validation, button states, response handling, integration
compare.test.js ~40+ METRICS, formatNum(), selection manager, search, radar normalization, table highlighting, insights (viability, elasticity, pressure, crosslinking)
quality.test.js ~100+ computeQualityScore(), getGrade(), pearsonR(), corrColor(), optimal ranges, weight customization, performer ranking, escapeHtml(), edge cases (empty data, single record, uniform values)
anomaly.test.js 61 computeStats(), getMetricValue(), Z-score detection, IQR detection, union (both) detection, severity classification, direction detection, single-metric filtering, threshold sensitivity, CSV/JSON export, formatNum, escapeHtml, edge cases (empty data, uniform values, broken objects)

Adding a New Metric

The backend is designed for easy metric extension. To add a new queryable metric:

1

Add the model property

If the data field doesn't exist in the model classes, add it to the appropriate class in Try/Models/Print.cs:

public class PrintData
{
    // ... existing properties ...
    
    /// <summary>
    /// Your new metric description.
    /// </summary>
    public double newMetric { get; set; }
}
2

Register the metric

Add one line to the MetricRegistry dictionary in PrintsController.cs:

{ "newMetric", new MetricDescriptor(p => p.print_data.newMetric, isInteger: false) }

That's it! The metric is now queryable at /api/prints/newMetric/{op}/{value} and automatically included in pre-computed statistics.

3

Update the frontend (optional)

Add the metric to the dropdown in docs/index.html and the getMetricValue() function. Add it to the METRICS array in docs/compare.html if you want it in comparisons.

Frontend Development

Project Structure

docs/
├── index.html        # Query tool (main page)
├── explorer.html     # Distribution + correlation charts
├── table.html        # Sortable/filterable data table
├── compare.html      # Multi-print comparison with radar chart
├── quality.html      # Quality control scoring dashboard
├── anomaly.html      # Statistical anomaly detector
├── api.html          # API reference documentation
├── architecture.html # Architecture documentation
├── guide.html        # This developer guide
└── bioprint-data.json

Conventions

Adding a New Page

  1. Copy an existing page as a template
  2. Add the page to the navigation bar in all existing pages
  3. Add a nav link in the docs pages sidebar
  4. The page will be automatically deployed via the Pages workflow

Docker

Build Locally

docker build -t biobots-tool .
docker run -p 8080:80 biobots-tool

Pull from Registry

docker pull ghcr.io/sauravbhattacharya001/biobots-tool:latest
docker run -p 8080:80 ghcr.io/sauravbhattacharya001/biobots-tool:latest

Custom Data Volume

docker run -p 8080:80 \
  -v /path/to/my-data.json:/app/bioprint-data.json:ro \
  biobots-tool

Contributing

Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes
  4. Run tests: npm test
  5. Commit with a descriptive message
  6. Push and open a Pull Request

Code Style

Commit Messages

Use Conventional Commits format:

feat: add new metric for print speed
fix: handle null crosslinking data
docs: update API reference with examples
test: add coverage for edge cases
chore: update dependencies

Troubleshooting

Common Issues

⚠️ NuGet restore fails
Make sure NuGet package sources are configured. Run nuget restore BioBotsTool.sln manually, or check that the nuget.org source is listed in your NuGet config.
⚠️ Tests fail with "Cannot find module"
Run npm install to install dependencies. The test suite requires jest and jest-environment-jsdom.
⚠️ Data file not found
Ensure bioprint-data.json is in the application root directory, or set the DataFilePath in Web.config. The file path is logged via Trace on startup.
⚠️ Port conflict on launch
IIS Express may fail if the assigned port is in use. Right-click the project → Properties → Web → change the port number.
💡 Debug logging: The backend uses System.Diagnostics.Trace for logging. Enable trace listeners in Web.config to see cache reload messages, record counts, and timing info.