Skip to content

This project provides a simple API to compute the volume of uploaded `.stp`/`.step` CAD files using a Node.js (Express + TypeScript) upload service and a Python (FastAPI + OpenCascade) microservice.

Notifications You must be signed in to change notification settings

codingwithsaleem/step-volume-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STEP Volume Microservice

This project provides a simple API to compute the volume of uploaded .stp/.step CAD files using a Node.js (Express + TypeScript) upload service and a Python (FastAPI + OpenCascade) microservice.


🧱 Architecture

  • Node.js service: Handles file uploads, forwards files to Python, returns JSON.
  • Python service: Uses OpenCascade (via pythonocc-core) to parse STEP and compute volume.
  • Docker Compose: Orchestrates both services for easy setup.

🚀 Quick Start (Docker)

  1. Clone the repository and open the project folder.

  2. Build and start all services:

    docker compose up --build
  3. Test the API:

    curl -F "file=@/path/to/your/model.stp" http://localhost:3000/api/volume

    Response example:

    {
     "filename": "Cube 10x10.stp",
     "volume": 999.9999999999999,
     "units": "mm^3",
     "volume_mm": 999.9999999999999,
     "volume_cm": 0.9999999999999999,
     "volume_in": 0.06102374409473228,
     "original_units": "mm",
     "area": 599.9999999999999,
     "solids_count": 1,
     "faces_count": 6,
     "edges_count": 24

}


---

## 🐍 Python Service (py-service)

- **Location:** `py-service/`
- **Main dependencies:** `fastapi`, `uvicorn`, `pythonocc-core` (via conda)
- **Dockerfile:** Uses Miniconda for reliable OpenCascade install.
- **Endpoint:** `POST /volume` (accepts `.stp`/`.step` file, returns volume)

## 🟦 Node.js Service (node-service)

- **Location:** `node-service/`
- **Main dependencies:** `express`, `multer`, `axios`, `dotenv`, `typescript`
- **Handles:** File upload, forwards to Python, adds unit conversions to response.
- **Endpoint:** `POST /api/volume`

---

## 🛠️ Local Development (without Docker)

### 1. Python service

```sh
cd py-service
# (Recommended) Use conda for pythonocc-core:
conda create -n step-volume python=3.10 pythonocc-core fastapi uvicorn
conda activate step-volume
uvicorn main:app --reload --host 0.0.0.0 --port 8000

2. Node service

cd node-service
cp .env.example .env
npm install
npm run dev

📦 File Structure

step-volume/
├─ node-service/
│  ├─ src/
│  │  └─ server.ts
│  ├─ package.json
│  ├─ tsconfig.json
│  ├─ .env.example
│  └─ Dockerfile
├─ py-service/
│  ├─ main.py
│  ├─ requirements.txt
│  └─ Dockerfile
└─ docker-compose.yml

✅ Features

  • Upload .stp/.step files and get precise volume in model units, mm³, and cm³.
  • Clean separation: Node.js for web/API, Python for CAD math.
  • Dockerized, portable, and scalable.

⚠️ Notes

  • The Python Docker image is large (~6GB) due to OpenCascade and conda dependencies. This is normal for CAD/geometry workloads.
  • The service assumes STEP files use mm as the default unit unless otherwise specified in the file.
  • For more CAD features (bounding box, surface area, etc.), extend the Python service using pythonocc-core.

About

This project provides a simple API to compute the volume of uploaded `.stp`/`.step` CAD files using a Node.js (Express + TypeScript) upload service and a Python (FastAPI + OpenCascade) microservice.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published