Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# CI — her push/PR'da frontend + Rust kalite kapısı.
# Yerel pre-commit hook'unun (husky: lint-staged + typecheck + vitest) uzak aynası;
# hook atlanırsa (--no-verify) veya farklı ortamda bozulan bir şey varsa burada yakalanır.
name: CI

on:
push:
branches: [main, 'refactor/**', 'fix/**']
pull_request:
branches: [main]

jobs:
frontend:
name: Frontend (lint + typecheck + test + build)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run lint
- run: npm run typecheck
- run: npm test
- run: npx vite build

rust:
name: Rust (clippy + test)
runs-on: ubuntu-latest
defaults:
run:
working-directory: src-tauri
steps:
- uses: actions/checkout@v4
- name: Install Tauri Linux system deps
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev \
libayatana-appindicator3-dev librsvg2-dev libssl-dev
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- run: cargo clippy --all-targets -- -D warnings
- run: cargo test --lib
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,18 @@ Pure structural/readability pass, locked by a Vitest safety net so behaviour is

- **Undo/redo off-by-one fixed** (BUGS.md #1): replaced the single history array + index with an undo/redo **two-stack** model. The first action is now undoable; each undo/redo moves exactly one step; redo restores the latest state. Preserves the 50-step cap (`MAX_HISTORY`) and "compound action = single entry" (multi-move / paste / script batch). Characterization tests intentionally updated to the correct spec + 6 new tests → **72** frontend tests.
- **Monaco offline**: the Lua editor now loads from the local `monaco-editor` bundle (`loader.config({ monaco })`) with the editor web worker bundled via Vite `?worker`; a `strip-monaco-cdn` Vite plugin removes the jsDelivr default URL from `dist/`. Lazy boundary preserved (Monaco stays in its own chunk; initial app chunk unchanged ≈ 191 kB). Zero CDN references in the build output.

---

## Phase 10 — Repository Structure & Hygiene

Professional repo-layout pass; behavior-neutral except one flagged fix.

- **Lint debt**: fixed all 22 `no-unused-vars` warnings (dead constants, unused destructures, vestigial `rawText` state, an entire unused icon import block); eslint warnings 45 → 23 (remaining `any`/hooks/refresh debt documented as future work)
- **Grouping**: loose root components → `components/overlays/` (EditorLoading, KeyboardHelp, Notifications, ProgressOverlay); scattered sweep slice → `features/sweep/` (SweepDialog + useSweepStore + sweepRunner + sweepHelpers + test), matching the experiment/export pattern
- **Google Fonts CDN removed** (flagged fix): index.html loaded Inter + JetBrains Mono from jsDelivr-adjacent Google hosts and the CSP allowed it — contradicting the zero-network guarantee. Links removed, CSP tightened, Monaco/Ruler fonts switched to the self-hosted IBM Plex Mono (consistent online/offline)
- **Template assets dropped**: vite.svg/tauri.svg/react.svg deleted; favicon is now the real app icon (`public/icon.png` from `src-tauri/icons`)
- **Broken examples removed**: three root-level `.mflow` files used the pre-1.0 legacy schema (`mflow_version: 1`) and could never load; the valid examples live in `examples/projects/`
- **Rust deps pruned**: unused `uuid`, `ndarray`, `rayon` removed from Cargo.toml
- **CI added**: GitHub Actions workflow (frontend: lint/typecheck/vitest/build; rust: clippy + cargo test with webkit deps and cache)
- **Docs trued up**: ARCHITECTURE paths (utils → features), TESTING counts (29 → 36 Rust, phantom `test_clear` removed, 72-test frontend section added), README (CI badge, real examples tree, FORMULAS row, screenshots placeholder), stale CODE_QUALITY_REPORT deleted
8 changes: 4 additions & 4 deletions CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ gezinebilmeli. Uçtan uca akışlar için bkz. [`docs/CODE_MAP.md`](docs/CODE_MA

| Klasör | Sorumluluk | Örnek |
|---|---|---|
| `components/<Alan>/` | Görsel React bileşenleri, alana göre gruplu | `Canvas/`, `ResultsPanel/`, `Toolbar/`, `Sidebar/`, `PropertiesPanel/`, `StatusBar/`, `ScriptEditor/` |
| `features/<özellik>/` | Kendine yeten, dikey bir özelliğin tüm parçaları (UI + store + util) | `features/experiment/`, `features/export/` |
| `components/<Alan>/` | Görsel React bileşenleri, alana göre gruplu | `Canvas/`, `ResultsPanel/`, `Toolbar/`, `Sidebar/`, `PropertiesPanel/`, `StatusBar/`, `ScriptEditor/`, `overlays/` (toast/progress/yardım) |
| `features/<özellik>/` | Kendine yeten, dikey bir özelliğin tüm parçaları (UI + store + util) | `features/experiment/`, `features/export/`, `features/sweep/` |
| `hooks/` | Yeniden kullanılabilir React hook'ları; App orkestrasyonu hook'lara taşınır | `useProjectIO`, `useSimulationRun`, `useExportFlow`, `useScriptRun`, `useKeyboardShortcuts` |
| `stores/` | Zustand global state; her store tek bir alan | `useDesignStore` (tasarım+canvas), `useSimulationStore`, `useSweepStore`, `useUiStore` |
| `stores/` | Zustand global state; her store tek bir alan (feature'a özel store ilgili `features/` klasöründe) | `useDesignStore` (tasarım+canvas), `useSimulationStore`, `useUiStore`, `useProjectStore` |
| `types/` | Domain'e bölünmüş TypeScript tipleri + re-export hub | `component.ts`, `canvas.ts`, `simulation.ts`, `project.ts`, `experiment.ts`, `ui.ts`, `index.ts` |
| `utils/` | Saf, framework'süz yardımcılar (paylaşılan) | `portUtils`, `componentBbox`, `colormaps`, `sweepRunner` |
| `utils/` | Saf, framework'süz yardımcılar (paylaşılan) | `portUtils`, `componentBbox`, `colormaps`, `componentDefaults` |
| `theme/` | Tasarım token'ları ve renk kaynakları (JS tarafı kanonik) | `tokens.ts`, `componentColors.ts` |
| `templates/` | "Şablondan başla" başlangıç tasarımları | `starters.ts` |

Expand Down
38 changes: 15 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Mikroakışkan çip tasarımı ve simülasyonu için profesyonel masaüstü uygulaması. [Tauri v2](https://tauri.app/) (Rust backend + React frontend), AutoCAD/Fusion 360 tarzı bir CAD ergonomisiyle inşa edildi.

![Version](https://img.shields.io/badge/version-1.0.0-blue) ![License](https://img.shields.io/badge/license-MIT-green) ![Tauri](https://img.shields.io/badge/tauri-v2-orange) ![Tests](https://img.shields.io/badge/tests-36%20rust%20%2B%2072%20frontend-brightgreen)
[![CI](https://github.com/hccancan4/microflow-studio/actions/workflows/ci.yml/badge.svg)](https://github.com/hccancan4/microflow-studio/actions/workflows/ci.yml) ![Version](https://img.shields.io/badge/version-1.0.0-blue) ![License](https://img.shields.io/badge/license-MIT-green) ![Tauri](https://img.shields.io/badge/tauri-v2-orange) ![Tests](https://img.shields.io/badge/tests-36%20rust%20%2B%2072%20frontend-brightgreen)

---

Expand All @@ -12,19 +12,7 @@ Sürükle-bırak canvas editöründe 10 tip parametrik bileşenden mikroakışka

---

## Ekran Görüntüleri

> Görseller `docs/images/` altında. (Henüz eklenmediyse `npm run tauri dev` ile çalıştırıp çekilebilir.)

| Canvas editörü | CFD ısı haritası |
|---|---|
| ![Canvas](docs/images/canvas.png) | ![CFD](docs/images/cfd.png) |

| Sonuç panelleri | Parametre taraması |
|---|---|
| ![Sonuçlar](docs/images/results.png) | ![Tarama](docs/images/sweep.png) |

![Lua script editörü](docs/images/script.png)
> **Ekran görüntüleri:** henüz eklenmedi — `npm run tauri dev` ile çekilip `docs/images/` altına konacak.

---

Expand Down Expand Up @@ -217,6 +205,7 @@ MicroFlow Studio tamamen **offline** çalışan bir desktop uygulamasıdır:
| [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) | Frontend/backend katman, IPC komut listesi, veri akışı |
| [`docs/COMPONENTS.md`](docs/COMPONENTS.md) | 10 bileşen tipi, parametreler, port topoloji, direnç formülleri |
| [`docs/SIMULATION.md`](docs/SIMULATION.md) | Analitik ağ çözücü + CFD algoritmaları |
| [`docs/FORMULAS.md`](docs/FORMULAS.md) | Tüm fizik formülleri (direnç, Re, Dean, karıştırma) türetimleriyle |
| [`docs/SCRIPTING.md`](docs/SCRIPTING.md) | Lua API referansı + örnekler |
| [`docs/FILE_FORMAT.md`](docs/FILE_FORMAT.md) | `.mflow` JSON schema, GDS-II layer stratejisi |
| [`docs/SHORTCUTS.md`](docs/SHORTCUTS.md) | Tam klavye kısayolu tablosu |
Expand All @@ -230,17 +219,20 @@ MicroFlow Studio tamamen **offline** çalışan bir desktop uygulamasıdır:
```
examples/
data/
velocity_profile.csv — 200 μm kanalda parabolik hız ölçümü
pressure_drop.csv — Basınç düşümü vs debi, 5 kanal uzunluğu
mixing_efficiency.json — 4 Re'de karıştırma verimi
velocity_profile.csv — 200 μm kanalda parabolik hız ölçümü
velocity_profile_experiment.csv — Deney import diyaloğu için örnek ölçüm
pressure_drop.csv — Basınç düşümü vs debi, 5 kanal uzunluğu
pressure_drop_experiment.csv — Deney import diyaloğu için örnek ölçüm
mixing_efficiency.json — 4 Re'de karıştırma verimi (JSON formatı)
scripts/
basic_t_junction.lua — Chip API ile basit T-bağlantı
parametric_sweep.lua — Kanal genişliği taraması
gradient_generator.lua — Konsantrasyon gradiyent ağı
basic_t_junction.lua — Chip API ile basit T-bağlantı
parametric_sweep.lua — Kanal genişliği taraması
gradient_generator.lua — Konsantrasyon gradiyent ağı
droplet_generator.lua — Damla üreteci tasarımı (script ile)
parametric_mixer.lua — Parametrik serpantin mikser
projects/
t_junction_droplet.mflow — Damla üreteci tasarımı
serpentine_mixer.mflow — 8-dönüş serpantin mikser
parallel_channels.mflow — Paralel kanal ağı
t_junction_basic.mflow — Basit T-bağlantı tasarımı (uygulamada aç)
serpentine_mixer.mflow — Serpantin mikser tasarımı
```

---
Expand Down
19 changes: 12 additions & 7 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,24 @@ Stage coordinate system: 1 Konva unit = 1 μm, scaled by `canvas.zoom` with offs

- **`useScriptDispatcher`** — listens for `script-action` and `script-completed` Tauri events; batches `DesignAction` payloads and dispatches them to `useDesignStore` methods; returns `ScriptRunStatus`.

### Utilities
### Feature modules & utilities

Vertical feature slices live under `src/features/<name>/` (UI + store + utils
co-located); shared, framework-free helpers stay in `src/utils/`.

| File | Purpose |
|---|---|
| `utils/gdsGeometry.ts` | Generate `GdsPolygon[]` from `ChipComponent[]` (265 lines) |
| `utils/svgExporter.ts` | Build SVG string from design; optional scale bar (249 lines) |
| `utils/experimentMetrics.ts` | R², RMSE, per-point error map computation (110 lines) |
| `utils/sweepRunner.ts` | Batch sweep execution loop (129 lines) |
| `utils/csvParser.ts` | CSV text → `ExperimentDataSet` (157 lines) |
| `features/export/gdsGeometry.ts` | Generate `GdsPolygon[]` from `ChipComponent[]` |
| `features/export/svgExporter.ts` | Build SVG string from design; optional scale bar |
| `features/export/exportRenderer.tsx` | Off-screen Konva `<Stage>` → base64 PNG for export |
| `features/experiment/experimentMetrics.ts` | R², RMSE, per-point error map computation |
| `features/experiment/csvParser.ts` | CSV/JSON text → `ExperimentDataSet` |
| `features/sweep/sweepRunner.ts` | Batch sweep execution loop |
| `features/sweep/sweepHelpers.ts` | Sweepable parameter catalog per component type |
| `utils/colormaps.ts` | viridis / jet / plasma / coolwarm lookup tables |
| `utils/componentDefaults.ts` | Default parameter values per component type |
| `utils/portUtils.ts` | Port position calculation in component-local coordinates |
| `utils/exportRenderer.tsx` | Off-screen Konva `<Stage>` → base64 PNG for export |
| `utils/componentBbox.ts` | Rotation-aware bounding boxes (selection, fit-all) |

---

Expand Down
4 changes: 3 additions & 1 deletion docs/CODE_MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Store güncellenir ──► ilgili panel render olur
| Direnç modeli + kanal default geometrileri | `src-tauri/src/simulation/analytic.rs` (`ASPECT_RATIO_CORRECTION`, `DEFAULT_CHANNEL_*_UM`) |
| `.mflow` dosya şeması | `types/project.ts` + `src-tauri/src/project/mod.rs` |
| Tipler (domain'e bölünmüş) | `types/<domain>.ts` (`component`, `canvas`, `simulation`, `project`, `experiment`, `ui`) |
| Sweep feature (dialog + store + runner + helpers) | `features/sweep/` |
| Overlay/feedback bileşenleri (toast, progress, kısayol yardımı, lazy spinner) | `components/overlays/` |
| Monaco editör offline kurulumu (yerel bundle + worker, CDN yok) | `components/ScriptEditor/monacoSetup.ts` + `vite.config.ts` (`strip-monaco-cdn`) |
| Bilinen latent bug'lar | [`../BUGS.md`](../BUGS.md) |

Expand All @@ -63,7 +65,7 @@ Store güncellenir ──► ilgili panel render olur
→ `CfdField` → `useSimulationStore` → `components/ResultsPanel/tabs/CfdView.tsx`

### Parametre Taraması (sweep)
`SweepDialog` → `stores/useSweepStore` + `utils/sweepRunner.ts` (her adımda analitik koşu)
`features/sweep/SweepDialog.tsx` → `features/sweep/useSweepStore.ts` + `features/sweep/sweepRunner.ts` (her adımda analitik koşu)
→ `components/ResultsPanel/tabs/SweepTab.tsx` (canlı grafik + CSV dışa aktar)

### Dışa Aktarma (PNG / SVG / GDS-II)
Expand Down
137 changes: 0 additions & 137 deletions docs/CODE_QUALITY_REPORT.md

This file was deleted.

Loading
Loading