Get the Code

Download

Download the complete Sansqrit codebase β€” Rust engine, Python tools, DSL interpreter, 639 blocks, and visual canvas.

Download Options

Clone from Git

# Clone the full repository
git clone https://github.com/your-org/sansqrit.git
cd sansqrit

# Install Node.js dependencies (requires npm)
npm install

# Build Rust WASM engine (requires Rust + wasm-pack)
bash build.sh

# Generate pre-computed tables (requires Python 3.8+)
python3 precompute.py

# Run all tests
npm test         # 39 core tests
npm run test:adv  # 32 advanced DSL tests

# Start the application
npm start
# Open http://localhost:3000

File Structure

sansqrit/
β”œβ”€β”€ build.sh                    ← One-command Rustβ†’WASM build
β”œβ”€β”€ package.json                ← npm configuration
β”œβ”€β”€ precompute.py               ← Python pre-computation script (1248 lines)
β”‚
β”œβ”€β”€ quantum_engine/             ← Rust crate
β”‚   β”œβ”€β”€ Cargo.toml
β”‚   └── src/lib.rs              ← 442 lines, all gates, 12 tests
β”‚
β”œβ”€β”€ wasm_pkg/                   ← Generated by wasm-pack (not in git)
β”‚   β”œβ”€β”€ quantum_engine.js
β”‚   └── quantum_engine_bg.wasm  ← ~178 KB compiled binary
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ engine/
β”‚   β”‚   β”œβ”€β”€ quantum.js          ← JS engine fallback (798 lines)
β”‚   β”‚   └── quantum_wasm.js     ← WASM bridge (336 lines)
β”‚   β”œβ”€β”€ dsl/
β”‚   β”‚   β”œβ”€β”€ interpreter.js      ← DSL interpreter (1064 lines)
β”‚   β”‚   └── stdlib.js           ← 200+ stdlib functions (1184 lines)
β”‚   β”œβ”€β”€ blocks/
β”‚   β”‚   β”œβ”€β”€ registry.js         ← Blocks 1-180 (1937 lines)
β”‚   β”‚   β”œβ”€β”€ registry_extra.js   ← Blocks 181-360 (1341 lines)
β”‚   β”‚   └── registry_extra_b.js ← Blocks 361-528 (992 lines)
β”‚   β”œβ”€β”€ server/server.js        ← Express + WebSocket
β”‚   └── export/circuit_export.js← 10 export formats
β”‚
β”œβ”€β”€ public/                     ← Web UI
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ css/style.css
β”‚   └── js/ app.js canvas.js palette.js properties.js
β”‚
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test.js                 ← 39 core tests
β”‚   └── test_dsl_advanced.js    ← 32 advanced tests
β”‚
└── precomputed/                ← Generated by precompute.py
    β”œβ”€β”€ gate_matrices.json
    β”œβ”€β”€ qft_matrices.json
    └── ... (8 files total)

Extract Rust Engine

To use only the Rust quantum engine in your own project:

# 1. Copy the quantum_engine folder into your project
cp -r sansqrit/quantum_engine my-project/

# 2. Add to your Cargo.toml:
# [dependencies]
# quantum-engine = { path = "./quantum_engine", features = ["wasm"] }

# 3. Build for WASM
cd quantum_engine
wasm-pack build --target bundler --out-dir ../wasm_pkg --release
// In your Rust code:
use quantum_engine::{QReg, QAlg};

fn main() {
    let mut q = QReg::new("q", 4);
    q.H_all();  // Hadamard on all 4 qubits
    let hist = q.measure_all(1000);
    println!("{:?}", hist);
}

Extract Python Tools

# Copy just the Python pre-computation script
cp sansqrit/precompute.py my-project/

# Run it (no dependencies beyond Python stdlib + optional numpy)
python3 precompute.py
python3 precompute.py --check    # verify output

# Optional: install numpy for 3x faster QFT matrix generation
pip install numpy

Firebase Hosting

This website is designed for Firebase Hosting. Deploy in 3 commands:

# 1. Install Firebase CLI
npm install -g firebase-tools

# 2. Login to Firebase
firebase login

# 3. Deploy
firebase deploy

# Your site will be live at:
# https://sansqrit.web.app