How dev-strzx9/sop works
SOP Studio is a browser-based standard-operating-procedure editor backed by a FastAPI service and PostgreSQL. The main workflow is: a user opens the editor, lists or opens a SOP, edits it, and saves a new version; the server validates and derives searchable fields, resolves SOP references, and persists document and version data. Separate API capabilities manage edit locks and version history/diffs. The graph reflects documented wiring and sampled calls; some route internals and the editor’s API calls are only described in the README or source comments.
Main entry points: main.py FastAPI application · sops.py SOP documents · db.py PostgreSQL connection pool · versions.py Version history
Components 18
Editor client
- Browser editor
static/SOP_STUDIO.html
API service
- Server entrypoint
app.py - FastAPI application
app/main.py - Runtime settings
app/config.py - User header
app/deps.py - API schemas
app/schemas.py - Error handling
app/errors.py
SOP domain
- SOP documents
app/routers/sops.py - Document validation
app/derive.py - SOP references
app/refs.py - Version history
app/routers/versions.py - Edit locks
app/routers/locks.py - Shared document helpers
app/routers/common.py
Persistence
- PostgreSQL connection pool
app/db.py - PostgreSQL
sql/sop_schema.sql
Schema operations
- Schema application
app/tools/apply_schema.py - Schema migrations
sql/migrations/001_ref_document_id.sql
Other components
- SOP user
Connections 28
- SOP user → Browser editor: edits SOPs
README.md - Browser editor → FastAPI application: uses API
README.md - FastAPI application → Browser editor: serves editor
app/main.py - Server entrypoint → FastAPI application: starts
README.md - FastAPI application → Runtime settings: loads settings
app/main.py - FastAPI application → PostgreSQL connection pool: opens pool
app/main.py - FastAPI application → Error handling: registers handlers
app/main.py - FastAPI application → SOP documents: mounts routes
app/main.py - FastAPI application → Version history: mounts routes
app/main.py - FastAPI application → Edit locks: mounts routes
app/main.py - FastAPI application → User header: guards API
app/main.py - SOP documents → PostgreSQL connection pool: queries through
app/routers/sops.py - SOP documents → Document validation: validates documents
app/routers/sops.py - SOP documents → SOP references: resolves references
app/routers/sops.py - SOP documents → Shared document helpers: uses helpers
app/routers/sops.py - SOP documents → API schemas: uses models
app/routers/sops.py - Version history → PostgreSQL connection pool: queries through
app/routers/versions.py - Version history → Shared document helpers: uses helpers
app/routers/versions.py - Version history → SOP references: loads references
app/routers/versions.py - Version history → API schemas: uses models
app/routers/versions.py - Edit locks → PostgreSQL connection pool: queries through
app/routers/locks.py - Edit locks → Shared document helpers: uses helpers
app/routers/locks.py - Edit locks → API schemas: uses models
app/routers/locks.py - PostgreSQL connection pool → Runtime settings: uses DB config
app/db.py - PostgreSQL connection pool → PostgreSQL: connects to
README.md - Schema application → Runtime settings: reads config
app/tools/apply_schema.py - Schema application → PostgreSQL: applies schema
README.md - Schema application → Schema migrations: applies changes
README.md