# ffroliva/sharpit architecture

> Architecture diagram of the GitHub repository ffroliva/sharpit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ffroliva/sharpit
- Repository: https://github.com/ffroliva/sharpit

## Overview

sharpit is a developer console and test-time safety gate for Python web applications, principally FastAPI/Starlette, with Flask support for pytest gates. The main workflow installs the adapter into an app, captures runtime and application facts, exposes panels through an API and browser UI, and lets developers inspect findings. Separately, pytest can collect per-test evidence and fail gates on regressions. The README documents these capabilities; sampled sources confirm selected advisor, routing, UI, and shared-state relationships, but not every panel’s wiring.

Main entry points: [`src/sharpit/fastapi/install.py`](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/fastapi/install.py) (Framework install), [`src/sharpit/engine/advisors/scan.py`](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/advisors/scan.py) (Advisor scans), [`src/sharpit/engine/capture`](https://github.com/ffroliva/sharpit/tree/main/src/sharpit/engine/capture) (Runtime capture), [`src/sharpit/pytest_plugin`](https://github.com/ffroliva/sharpit/tree/main/src/sharpit/pytest_plugin) (Pytest adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["App integration"]
  node_install["Framework install<br/>[install.py]"]
  node_activation["Activation and access<br/>[activation.py]"]
  node_app_introspection["App introspection<br/>[introspector.py]"]
  node_context["Install context<br/>[context.py]"]
end

subgraph group_capture["Runtime evidence"]
  node_capture["Runtime capture"]
  node_insights["Runtime insights<br/>[service.py]"]
  node_collectors["Panel collectors"]
  node_masking["Secret masking<br/>[masking.py]"]
end

subgraph group_analysis["Advisors and findings"]
  node_advisors["Advisor scans<br/>[scan.py]"]
  node_advisor_report["Advisor reports<br/>[report.py]"]
  node_rest_advisor["REST API advisor<br/>[service.py]"]
  node_database_advisor["Database advisor<br/>[report.py]"]
  node_vuln_scan["Vulnerability scan<br/>[service.py]"]
end

subgraph group_interfaces["Console interfaces"]
  node_api_routes["Console API routes"]
  node_ui_shell["Console UI shell<br/>[App.svelte]"]
  node_ui_api["UI API client<br/>[api.ts]"]
  node_ui_views["Panel views"]
  node_cli["CLI and MCP tools<br/>[client.py]"]
end

subgraph group_testing["Test gates"]
  node_pytest_plugin["Pytest adapter"]
  node_gate_session["Gate session"]
  node_test_report["Gate reports<br/>[report.py]"]
end

node_developer(("Developer"))
node_webapp["Python web app"]
node_browser(("Browser"))
node_pytest(("Pytest runner"))

node_developer -->|"installs"| node_install
node_webapp -->|"mounts console"| node_install
node_install -.->|"checks activation"| node_activation
node_install -.->|"creates context"| node_context
node_install -.->|"adapts app"| node_app_introspection
node_webapp -->|"emits runtime evidence"| node_capture
node_capture -->|"journals evidence"| node_insights
node_capture -.->|"supplies panel data"| node_collectors
node_masking -->|"masks values"| node_collectors
node_developer -->|"requests scan"| node_advisors
node_advisors -->|"builds report"| node_advisor_report
node_rest_advisor -->|"runs shared scan"| node_advisors
node_database_advisor -->|"uses findings"| node_advisors
node_developer -->|"requests scan"| node_vuln_scan
node_browser -->|"opens console"| node_ui_shell
node_ui_shell -->|"renders panels"| node_ui_views
node_ui_views -->|"requests data"| node_ui_api
node_ui_api -->|"calls API"| node_api_routes
node_api_routes -->|"serves advisor"| node_database_advisor
node_developer -.->|"uses tools"| node_cli
node_pytest -->|"loads plugin"| node_pytest_plugin
node_pytest_plugin -.->|"records test evidence"| node_gate_session
node_gate_session -.->|"writes findings"| node_test_report
node_pytest_plugin -->|"runs route advisor"| node_rest_advisor

click node_install "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/fastapi/install.py"
click node_activation "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/activation.py"
click node_app_introspection "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/fastapi/introspector.py"
click node_context "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/context.py"
click node_capture "https://github.com/ffroliva/sharpit/tree/main/src/sharpit/engine/capture"
click node_insights "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/collectors/insights/service.py"
click node_collectors "https://github.com/ffroliva/sharpit/tree/main/src/sharpit/engine/collectors"
click node_masking "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/masking.py"
click node_advisors "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/advisors/scan.py"
click node_advisor_report "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/advisors/report.py"
click node_rest_advisor "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/collectors/restapi/service.py"
click node_database_advisor "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/collectors/database_advisor/report.py"
click node_vuln_scan "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/collectors/vulns/service.py"
click node_api_routes "https://github.com/ffroliva/sharpit/tree/main/src/sharpit/fastapi/routes"
click node_ui_shell "https://github.com/ffroliva/sharpit/blob/main/ui/src/App.svelte"
click node_ui_api "https://github.com/ffroliva/sharpit/blob/main/ui/src/lib/api.ts"
click node_ui_views "https://github.com/ffroliva/sharpit/tree/main/ui/src/views"
click node_cli "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/cli/client.py"
click node_pytest_plugin "https://github.com/ffroliva/sharpit/tree/main/src/sharpit/pytest_plugin"
click node_gate_session "https://github.com/ffroliva/sharpit/tree/main/src/sharpit/engine/testsession"
click node_test_report "https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/testsession/report.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_install,node_activation,node_app_introspection,node_context,node_browser toneBlue
class node_capture,node_insights,node_collectors,node_masking toneAmber
class node_advisors,node_advisor_report,node_rest_advisor,node_database_advisor,node_vuln_scan toneMint
class node_api_routes,node_ui_shell,node_ui_api,node_ui_views,node_cli toneRose
class node_pytest_plugin,node_gate_session,node_test_report,node_developer,node_webapp,node_pytest toneIndigo
```

## Components

### App integration

- [Framework install](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/fastapi/install.py): `src/sharpit/fastapi/install.py`
- [Activation and access](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/activation.py): `src/sharpit/engine/activation.py`
- [App introspection](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/fastapi/introspector.py): `src/sharpit/fastapi/introspector.py`
- [Install context](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/context.py): `src/sharpit/engine/context.py`

### Runtime evidence

- [Runtime capture](https://github.com/ffroliva/sharpit/tree/main/src/sharpit/engine/capture): `src/sharpit/engine/capture`
- [Runtime insights](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/collectors/insights/service.py): `src/sharpit/engine/collectors/insights/service.py`
- [Panel collectors](https://github.com/ffroliva/sharpit/tree/main/src/sharpit/engine/collectors): `src/sharpit/engine/collectors`
- [Secret masking](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/masking.py): `src/sharpit/engine/masking.py`

### Advisors and findings

- [Advisor scans](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/advisors/scan.py): `src/sharpit/engine/advisors/scan.py`
- [Advisor reports](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/advisors/report.py): `src/sharpit/engine/advisors/report.py`
- [REST API advisor](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/collectors/restapi/service.py): `src/sharpit/engine/collectors/restapi/service.py`
- [Database advisor](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/collectors/database_advisor/report.py): `src/sharpit/engine/collectors/database_advisor/report.py`
- [Vulnerability scan](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/collectors/vulns/service.py): `src/sharpit/engine/collectors/vulns/service.py`

### Console interfaces

- [Console API routes](https://github.com/ffroliva/sharpit/tree/main/src/sharpit/fastapi/routes): `src/sharpit/fastapi/routes`
- [Console UI shell](https://github.com/ffroliva/sharpit/blob/main/ui/src/App.svelte): `ui/src/App.svelte`
- [UI API client](https://github.com/ffroliva/sharpit/blob/main/ui/src/lib/api.ts): `ui/src/lib/api.ts`
- [Panel views](https://github.com/ffroliva/sharpit/tree/main/ui/src/views): `ui/src/views`
- [CLI and MCP tools](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/cli/client.py): `src/sharpit/cli/client.py`

### Test gates

- [Pytest adapter](https://github.com/ffroliva/sharpit/tree/main/src/sharpit/pytest_plugin): `src/sharpit/pytest_plugin`
- [Gate session](https://github.com/ffroliva/sharpit/tree/main/src/sharpit/engine/testsession): `src/sharpit/engine/testsession`
- [Gate reports](https://github.com/ffroliva/sharpit/blob/main/src/sharpit/engine/testsession/report.py): `src/sharpit/engine/testsession/report.py`

### Other components

- **Developer**
- **Python web app**
- **Browser**
- **Pytest runner**

## Connections

- Developer → Framework install: installs (evidence: `README.md`)
- Python web app → Framework install: mounts console (evidence: `README.md`)
- Framework install → Activation and access: checks activation
- Framework install → Install context: creates context
- Framework install → App introspection: adapts app
- Python web app → Runtime capture: emits runtime evidence (evidence: `README.md`)
- Runtime capture → Runtime insights: journals evidence (evidence: `src/sharpit/engine/collectors/insights/service.py`)
- Runtime capture → Panel collectors: supplies panel data
- Secret masking → Panel collectors: masks values (evidence: `src/sharpit/engine/collectors/postgresql/querytext.py`)
- Developer → Advisor scans: requests scan (evidence: `README.md`)
- Advisor scans → Advisor reports: builds report (evidence: `src/sharpit/engine/advisors/scan.py`)
- REST API advisor → Advisor scans: runs shared scan (evidence: `src/sharpit/engine/collectors/restapi/service.py`)
- Database advisor → Advisor scans: uses findings (evidence: `src/sharpit/engine/collectors/database_advisor/report.py`)
- Developer → Vulnerability scan: requests scan (evidence: `README.md`)
- Browser → Console UI shell: opens console (evidence: `README.md`)
- Console UI shell → Panel views: renders panels (evidence: `ui/src/App.svelte`)
- Panel views → UI API client: requests data (evidence: `ui/src/views/DatabaseAdvisor.svelte`)
- UI API client → Console API routes: calls API (evidence: `README.md`)
- Console API routes → Database advisor: serves advisor (evidence: `src/sharpit/fastapi/routes/database_advisor.py`)
- Developer → CLI and MCP tools: uses tools
- Pytest runner → Pytest adapter: loads plugin (evidence: `README.md`)
- Pytest adapter → Gate session: records test evidence (evidence: `src/sharpit/pytest_plugin/apps.py`)
- Gate session → Gate reports: writes findings
- Pytest adapter → REST API advisor: runs route advisor (evidence: `src/sharpit/pytest_plugin/apps.py`)
