Skip to content

M4rulli/Dynamica

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dynamica

Vite React TypeScript FastAPI Python SymPy Lcapy

Professional circuit editor with a modern UI, SVG/LaTeX export, and asynchronous API analysis (mesh/nodal workflows).

Highlights

  • Drag-and-drop circuit editor with snapping, labeling, and rotation.
  • Dedicated component inspector (labels, electrical parameters, unknown flags).
  • Export pipeline:
    • SVG (clean presentation output)
    • LaTeX (circuitikz)
  • Async analysis API with job polling.
  • Mesh analysis pipeline with current-source constraints and supermesh-aware equations.
  • Rich analysis report page:
    • interactive graph panel
    • incidence and mesh matrices
    • equation steps
    • branch table (I, V, P)
    • power-balance card

Architecture

Web

  • Stack: Vite + React + TypeScript
  • Main entry: web/src/main.ts
  • Key controllers:
    • web/src/controller/canvasController.ts: canvas state + interaction core
    • web/src/controller/componentInspectorController.ts: selected-component editing
    • web/src/controller/navbarController.ts: sidebar controls (theme/grid/export/analysis)
    • web/src/controller/analysisController.ts: analysis job submission
  • Analysis report:
    • web/pages/analysis.html
    • web/src/analysis/analysisMain.ts
    • web/src/analysis/analysisRenderer.ts

API

  • Stack: FastAPI + SymPy (+ Lcapy available in environment)
  • API entrypoint: api/app/main.py
  • Analysis routes: api/app/routes/analysis.py
  • General orchestration: api/app/core/analysis_engine.py
  • Mesh-specific algorithm: api/app/core/mesh_analysis.py
  • Shared utilities: api/app/core/analysis_common.py
  • In-memory job store: api/app/core/job_store.py

Quick Start

1) Web

macOS/Linux:

npm install
npm run dev

Windows CMD:

npm install
npm run dev

Default dev URL: http://127.0.0.1:5173

2) API

macOS/Linux (Unix):

cd api
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m uvicorn app.main:app --reload --port 8000

Windows CMD:

cd api
py -m venv .venv
.venv\Scripts\activate.bat
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m uvicorn app.main:app --reload --port 8000

Note:

  • Avvio corretto API: python -m uvicorn app.main:app --reload --port 8000
  • Non usare python app/main.py.
  • Per uscire dalla virtualenv: deactivate

Health check:

curl http://127.0.0.1:8000/health

3) Build

npm run build

Analysis API

Base URL: http://127.0.0.1:8000/api/v1

  • POST /analysis/jobs
    • Creates a new async analysis job.
  • GET /analysis/jobs/{job_id}
    • Returns job status (queued|running|completed|failed).
  • GET /analysis/jobs/{job_id}/result
    • Returns result payload when completed.

Notes:

  • Circuit integrity is validated before job enqueueing.
  • Missing required electrical parameters are rejected early.

Usage Flow

  1. Build a circuit in the editor.
  2. Set component parameters in Inspector.
  3. Run Analisi Nodi or Analisi Maglie.
  4. A report tab opens (/pages/analysis.html?job=...) and auto-polls results.
  5. Review graph/matrices/equations/table/power-balance.

Project Structure

.
├─ web/
│  ├─ src/                  # Web source (React + controllers)
│  ├─ public/static/        # Static UI fragments (navbar/grid/inspector)
│  ├─ pages/
│  │  ├─ editor.html
│  │  └─ analysis.html
│  └─ index.html
├─ config/                  # Build/TypeScript configuration
├─ api/
│  ├─ app/
│  │  ├─ main.py            # FastAPI app bootstrap + health
│  │  ├─ routes/
│  │  │  └─ analysis.py     # Analysis endpoints
│  │  └─ core/
│  │     ├─ analysis_engine.py # General dispatcher and validation
│  │     ├─ mesh_analysis.py   # Mesh analysis algorithm
│  │     ├─ analysis_common.py # Shared graph/latex/svg helpers
│  │     ├─ models.py          # Pydantic schemas
│  │     └─ job_store.py       # In-memory job store
│  └─ requirements.txt
└─ package.json

Development Notes

  • Editor and analysis pages are theme-aware (light/dark) via localStorage.
  • API debug traces can be enabled with:
export ANALYSIS_DEBUG=1

Roadmap

  • Full nodal solver parity with the current mesh reporting quality.
  • Stronger supermesh detection/annotation in the report UI.
  • Import/save persistence workflow (currently UI placeholders exist).
  • E2E regression tests for editor -> API -> report pipeline.
  • Optional persistent API job storage (Redis/PostgreSQL).

License

Specify project license here (e.g. MIT) before publishing.

About

Dynamica is a graphical analog circuit editor with advanced analysis capabilities, designed to bridge circuit theory, system dynamics, and symbolic computation.

Resources

Stars

Watchers

Forks

Contributors