Studio Setup Guide
Running Studio
The Studio provides a visual interface for designing DocTypes and managing your Framework M application.
Single Command
m studio --port 9999
This starts the Studio server with both the UI and API on a single port.
URL Structure
The Studio uses a path prefix architecture for clean separation:
-
UI:
http://127.0.0.1:9999/studio/ui/- Main interface for designing DocTypes
- All frontend routes are under
/studio/ui/*
-
API:
http://127.0.0.1:9999/studio/api/- Backend endpoints for data operations
- All API routes are under
/studio/api/*
-
Root:
http://127.0.0.1:9999/- Automatically redirects to
/studio/ui/
- Automatically redirects to
Development Mode
For frontend development with hot reload:
Terminal 1 - API Server:
m studio --port 9999
Terminal 2 - Frontend Dev Server:
cd apps/studio/studio_ui
pnpm dev
The Vite dev server runs on http://localhost:5173 with API proxying to port 9999.
Git Noise and Local Builds
Avoid running pnpm build locally during development.
Running pnpm build updates the static assets in apps/studio/src/framework_m_studio/static/. Since Vite includes hashes in filenames (e.g., index-a1b2c3.js), every build modifies tracked files, creating unnecessary git noise.
Best Practice:
- Use
pnpm devfor frontend development. - Rely on CI/CD for release builds. The pipeline automatically rebuilds the UI assets for PyPI packages.
- Local
pnpm buildis only necessary to verify production artifacts locally or update the repository snapshot.
Architecture
Path Prefix Separation
The Studio implements complete separation between UI and API routes:
/studio/ui/* → React SPA (HTML pages)
/studio/api/* → JSON API endpoints
/studio → Redirects to /studio/ui/
This architecture:
- ✅ Prevents route collisions
- ✅ Enables clean URLs (no hash fragments)
- ✅ Works with single-command deployment
- ✅ Supports proper Content-Type headers
Static Assets
Static assets (JS, CSS, images) are served at:
/studio/ui/assets/*
The Vite build process outputs to apps/studio/src/framework_m_studio/static/ which is included in the Python package.
API Endpoints
Health Check
curl http://127.0.0.1:9999/studio/api/health
List DocTypes
curl http://127.0.0.1:9999/studio/api/doctypes
Get DocType
curl http://127.0.0.1:9999/studio/api/doctype/User
Field Types
curl http://127.0.0.1:9999/studio/api/field-types
Building for Production
Build Frontend
cd apps/studio/studio_ui
pnpm build
This outputs to ../src/framework_m_studio/static/ which is packaged with the Python distribution.
Package Python
cd apps/studio
uv build
The built wheel includes the static frontend assets.
Troubleshooting
UI Downloads Instead of Rendering
If the browser downloads HTML files instead of rendering them, check:
- Content-Type Headers: Ensure responses have
Content-Type: text/html; charset=utf-8 - Route Handlers: Verify return type is
Responsenot union types - Browser Cache: Clear browser cache and hard reload (Ctrl+Shift+R)
404 Errors on Deep Links
If refreshing a page like /studio/ui/doctypes/edit/User gives 404:
- Check Route Handler: Ensure
/studio/ui/{path:path}wildcard route exists - SPA Fallback: Verify the handler returns
index.htmlfor non-file paths - Base Path: Confirm React Router uses
basename="/studio/ui"
API Calls Failing
If API calls return errors:
- CORS: Check CORS configuration allows your origin
- Path Prefix: Ensure API calls use
/studio/api/*prefix - Server Running: Verify
m studiois running on the correct port