🛠️ Developer Guide
Everything you need to set up, develop, test, and contribute to BioBots Tool.
Prerequisites
| Tool | Version | Purpose |
|---|---|---|
| Visual Studio | 2015+ | C# backend development |
| .NET Framework | 4.x | Runtime |
| Node.js | 18+ | Running JavaScript tests |
| npm | 9+ | Package management |
| Git | 2.x | Source control |
| Docker | (optional) | Container builds |
Setup
Clone the repository
git clone https://github.com/sauravbhattacharya001/BioBots.git cd BioBots
Install JavaScript dependencies
npm install
This installs Jest and jsdom for running the frontend test suite.
Open the solution in Visual Studio
start BioBotsTool.sln
Visual Studio will restore NuGet packages automatically.
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>
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
| File | Tests | What 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:
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; }
}
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.
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
- Self-contained pages: Each HTML file includes all CSS and JS inline — no build step required
- CSS custom properties: All colors use the
:rootvariables defined at the top - Canvas rendering: Charts use
<canvas>with direct 2D context calls — no charting libraries - Data loading: Each page loads
bioprint-data.jsonviafetch()on page load - No build step: Edit HTML files directly and refresh the browser
Adding a New Page
- Copy an existing page as a template
- Add the page to the navigation bar in all existing pages
- Add a nav link in the docs pages sidebar
- 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
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run tests:
npm test - Commit with a descriptive message
- Push and open a Pull Request
Code Style
- C#: Follow standard .NET naming conventions. XML doc comments on public members.
- JavaScript:
'use strict'mode.const/letovervar. Descriptive function names. - HTML/CSS: Semantic elements. CSS custom properties for colors. Mobile-responsive.
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
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.
Run
npm install to install dependencies. The test suite requires
jest and jest-environment-jsdom.
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.
IIS Express may fail if the assigned port is in use. Right-click the project → Properties → Web → change the port number.
System.Diagnostics.Trace
for logging. Enable trace listeners in Web.config to see cache reload
messages, record counts, and timing info.