9.6 KiB
mxpic_EDA Project Understanding
Purpose
mxpic_EDA is a local/intranet EDA web application for creating photonic integrated circuit layout projects. It combines:
- A Flask backend for authentication, project APIs, PDK browsing, layout persistence, preview generation, and GDS export.
- Static frontend pages for login, dashboard, and canvas editing.
- SQLite account/audit storage plus filesystem-based project layout storage.
- External build-time tooling (
mxpic_router, Nazca, and sometimesgdstk) for routed SVG preview and final GDS generation.
The project is designed so normal login, dashboard, canvas editing, YAML generation, and PDK browsing can run without importing the router stack. Build actions load those heavier dependencies only when needed.
Main Entry Points
Start the App
The intended intranet startup path is:
.\run_intranet_server.ps1
That script sets:
MXPIC_HOST=0.0.0.0MXPIC_PORT=3000MXPIC_DEBUG=0- a fallback
MXPIC_SECRET_KEYif none is set
Then it runs:
python backend\server.py
The server listens on:
http://<host-computer-ip>:3000
Default local accounts are:
admin / 123456
engineer / 123456
admin is a manager account. engineer is a developer account.
Repository Structure
backend/
server.py Flask app, routes, project/layout APIs
database.py SQLite initialization, users, profiles, audit logs
pdk_access.py Role-aware PDK root selection and export helpers
gds_builder.py Final GDS wrapper around mxpic_router
routed_layout_preview.py SVG preview generation via temporary routed GDS
router_dependency.py Lazy build-time dependency validation
technology_manifest.py technology.yml loading/validation
icons/ Category icons served by backend
frontend/
login.html Login page
dashboard.html Project/account dashboard
canvas.html Main layout editor
canvas-helpers.js Canvas/YAML/route helper functions and tests target
database/
mxpic_data.db SQLite app database
<username>/layout/... Saved project metadata, YAML cells, SVG previews
_exports/<uuid>/... Temporary generated GDS downloads
docs/
INTRANET_DEPLOYMENT.md
GDS_SVG_GENERATION_LOGIC.md
PDK_TECHNOLOGY_XSECTION_LOADING.md
tests/
JavaScript assertion tests for static wiring and canvas helpers
User Workflow
- User opens
/. - If not logged in, Flask serves
frontend/login.html. - Login form posts credentials to
POST /login. - On success, the session stores user id, username, and user group.
- User lands on
/dashboard. - Dashboard loads:
/api/profile/api/logs/api/projects/api/technologies
- User creates or opens a project.
- Creating a project posts
{ name, technology }toPOST /api/projects. - Opening a project navigates to
/canvas?project=<project>. - Canvas loads project data from
/api/projects/<project>. - Canvas loads the selected
technology.ymlmanifest from/api/technologies/<foundry>/<technology>/manifest. - Canvas loads the project-scoped PDK library from
/api/library?project=<project>. - User places components, elements, pins, and routes.
- Save or Build Layout writes YAML to disk through
/api/save-layout. - Build Layout also generates and opens an SVG preview.
- Build GDS calls
/api/build-gdsand downloads the generated GDS.
Project and Data Model
Each user's projects live under:
database/<username>/layout/<project>/
Project metadata is stored in:
database/<username>/layout/<project>/.project.json
Example:
{
"name": "mxpic_project_1",
"technology": "Silterra/EMO1_2ML_CU_Al_RDL"
}
Saved cells are YAML files:
database/<username>/layout/<project>/<cell>.yml
Generated previews are SVG files:
database/<username>/layout/<project>/<cell>.svg
Modern saved layout YAML contains:
schema_versionkindcoordinate_systemcanvas_sizeprojectnametypeversionpinsinstanceselementsbundles
instances reference basic components, forge/generated components, other project cells, or PDK component paths. bundles store routed links and route settings such as xsection, family, width, radius, and routing_type.
PDK and Technology Workflow
The active PDK root is chosen by user role:
manager:MXPIC_PDK_ATLAS_ROOToropt_pdk_atlas/foundriesdevelopersanduser:MXPIC_PDK_PUBLIC_ROOToropt_pdk_public/foundries
The dashboard lists available technologies by scanning:
<active_role_pdk_root>/<foundry>/<technology>/technology.yml
The selected technology is saved in .project.json.
Canvas then uses that selected technology to:
- Load route defaults and xsections from
technology.yml. - Scope the component library browser to the chosen foundry/technology.
- Save component paths that can later resolve under the base role PDK root.
At build time, the router receives the active PDK root and the selected project's technology manifest path. The router applies technology layers/xsections to Nazca before resolving PDK assets and routing links.
Build Layout vs Save vs Build GDS
Save
The canvas "Save" path calls handleSaveProjectLayouts. It writes YAML for every editable project/cell page to /api/save-layout with preview disabled. It is for persistence, not preview.
Build Layout
The canvas "Build Layout" path:
- Validates route crossings.
- Serializes the active page to YAML.
- Posts to
/api/save-layout. - Backend writes
<cell>.yml. - Backend writes route sidecar data when available.
- Backend calls
routed_layout_preview.py. routed_layout_preview.pycallsmxpic_router.build_project_gds.- The temporary routed GDS is converted to
<cell>.svgwithgdstk. - Frontend opens the SVG preview tab.
Build GDS
The canvas "Build GDS" path:
- Validates route crossings across editable pages.
- Posts
{ project }to/api/build-gds. - Backend reads saved YAML files already on disk.
- Backend creates
database/_exports/<uuid>/<project>.gds. backend/gds_builder.pydelegates tomxpic_router.build_project_gds.- Backend returns
download_url. - Frontend triggers a browser download.
- Backend removes the temporary export folder after serving the file.
Important: Build GDS does not serialize unsaved in-memory canvas state first. Users should Save or Build Layout before Build GDS if they want latest canvas edits included.
Backend API Map
Primary pages:
GET /POST /loginGET /dashboardGET /canvasGET /canvas-helpers.jsGET /logout
Account and activity:
GET /api/healthGET/PATCH /api/profilePOST /api/profile/passwordGET/POST /api/logs
Projects and cells:
GET /api/projectsPOST /api/projectsGET /api/projects/<project_name>DELETE /api/projects/<project_name>PATCH/DELETE /api/projects/<project_name>/cells/<cell_name>POST /api/save-layoutGET /api/projects/<project_name>/cells/<cell_name>/layout.svg
Build/export:
POST /api/build-gdsGET /api/exports/<export_id>/<filename>GET /api/projects/<project_name>/gds/<filename>
PDK/technology/library:
GET /api/technologiesGET /api/technologies/<foundry>/<technology>/manifestGET /api/libraryGET /api/component/<component_name>GET /api/component/<component_name>/imageGET /api/icon/<category>
Persistence and Accounts
SQLite database:
database/mxpic_data.db
Tables observed:
usersuser_logs
The backend initializes the database on startup. It also performs lightweight migrations for profile, credit, occupation, and group fields.
User groups affect PDK access:
managercan use atlas/private PDK roots and prefers full GDS assets.developersanduseruse the public PDK roots.
Audit logs record user actions with project/cell context, details, IP address, and UTC timestamp.
Tests
Tests are JavaScript assertion scripts under tests/.
The suite mostly checks integration contracts by reading source files, including:
- API route strings and handler wiring.
- Build Layout and Build GDS frontend/backend wiring.
- Removal of legacy local preview/PDK registry modules.
- Router-backed GDS and SVG preview paths.
- Technology manifest and PDK access behavior.
- Canvas helper behavior such as pin/handle placement, YAML serialization, route defaults, route YAML, element ports, and route crossing checks.
Likely command:
node --test tests
Current Repository State Notes
This checkout contains unresolved merge-conflict markers in some tracked files:
database/engineer/layout/mxpic_project_1/mxpic_project_1.ymldatabase/engineer/layout/mxpic_project_1/mxpic_project_1.svgtests/layout-ui-wiring.test.jstests/layout-backend-static.test.js
That means some checked sample data may not parse as YAML/SVG, and the test suite may fail before reaching assertions until those files are cleaned.
The checked admin and engineer project metadata both select:
Silterra/EMO1_2ML_CU_Al_RDL
Mental Model
Think of this app as:
Flask session/account layer
-> role-scoped PDK/technology selection
-> dashboard project metadata
-> canvas layout editing
-> YAML saved on disk
-> mxpic_router/Nazca build path
-> SVG preview or downloadable GDS
The repository itself owns the web UI, persistence, API contracts, and orchestration. The actual routed photonic layout build is intentionally delegated to the external mxpic_router stack.