The node editor now uses SQLite database instead of hardcoded data.
┌─────────────────┐ HTTP ┌─────────────────┐ SQL ┌─────────────────┐
│ │ ──────────────> │ │ ────────────> │ │
│ node-editor │ GET /api/ │ Flask API │ SELECT * │ SQLite DB │
│ .html │ components │ (api.py) │ FROM ... │ (components │
│ (Frontend) │ │ (Backend) │ │ .db) │
│ │ <────────────── │ │ <──────────── │ │
└─────────────────┘ JSON └─────────────────┘ Results └─────────────────┘
components.db.sql- Database schema and sample dataapi.py- Flask API servernode-editor.html- Frontend (modified to fetch from API)requirements.txt- Python dependenciessetup.sh- Setup script
pip install -r requirements.txtpython3 api.pyThis will automatically create components.db from the schema file.
Open node-editor.html in your browser (or use the local server):
python3 -m http.server 9999
# Then open: http://localhost:9999/node-editor.html| Column | Type | Description |
|---|---|---|
| id | INTEGER | Primary key |
| name | TEXT | Component name (unique) |
| created_at | TIMESTAMP | Creation timestamp |
| Column | Type | Description |
|---|---|---|
| id | INTEGER | Primary key |
| component_id | INTEGER | Foreign key to components |
| name | TEXT | Parameter name |
| datatype | TEXT | Data type (float, int, boolean, string) |
| default_value | TEXT | Default value |
| description | TEXT | Parameter description |
| options | TEXT | JSON array for dropdown options |
Returns all components with their parameters.
Response:
[
{
"name": "darts",
"parameters": [
{
"name": "x",
"datatype": "float",
"defaultValue": 0.0,
"description": "X coordinate"
},
{
"name": "y",
"datatype": "float",
"defaultValue": 0.0,
"description": "Y coordinate"
}
]
}
]sqlite3 components.db-- Add new component
INSERT INTO components (name) VALUES ('my_component');
-- Add parameters (replace component_id with actual ID)
INSERT INTO parameters (component_id, name, datatype, default_value, description)
VALUES (6, 'my_param', 'float', '1.0', 'My parameter description');import sqlite3
conn = sqlite3.connect('components.db')
cursor = conn.cursor()
# Insert component
cursor.execute("INSERT INTO components (name) VALUES (?)", ('my_component',))
component_id = cursor.lastrowid
# Insert parameters
cursor.execute("""
INSERT INTO parameters (component_id, name, datatype, default_value, description)
VALUES (?, ?, ?, ?, ?)
""", (component_id, 'my_param', 'float', '1.0', 'My parameter'))
conn.commit()
conn.close()Edit components.db.sql, then:
rm components.db
python3 api.py # Will recreate from schema- Make sure Flask API is running:
python3 api.py - Check console for errors
- Verify API is accessible:
curl http://localhost:5000/api/components
flask-corsshould handle this automatically- If issues persist, check browser console
- Only one process can write to SQLite at a time
- Close other connections to
components.db
sqlite3 components.db
sqlite> .tables
sqlite> SELECT * FROM components;
sqlite> .quitrm components.db
python3 api.pycurl http://localhost:5000/api/components | jqFor production use, consider:
- Use PostgreSQL/MySQL instead of SQLite for concurrent access
- Add authentication to API
- Add validation for component data
- Add API endpoints for CREATE/UPDATE/DELETE operations
- Use proper WSGI server (gunicorn/uwsgi) instead of Flask dev server
The original hardcoded data has been migrated to SQLite:
- 5 components (darts, linear_model, data_processor, evaluator, neural_network)
- 13 total parameters
- All data types supported (float, int, boolean, string with options)
Data is preserved and now editable via database!