@startuml
!theme reddress-darkblue

title Overall System Diagram

actor "USERS" as Users
actor "Tool Publisher\n(Gitea account required)" as ToolPublisher

rectangle "smarttools CLI" as CLI
note right of CLI
  - registry search
  - registry install
  - registry publish
  - registry browse (TUI)
end note

rectangle "Web UI (future)" as WebUI
note right of WebUI
  - Browse tools
  - Search
  - View tool details
end note

component "REGISTRY API SERVER\n(Flask/FastAPI)" as APIServer
note right of APIServer
  <b>Host:</b> gitea.brrd.tech/api/registry
  --
  <b>Endpoints:</b>
  - GET  /tools
  - GET  /tools/search?q=...
  - GET  /tools/{name}
  - GET  /tools/{name}/download
  - POST /tools (creates PR)
  - GET  /categories
  - GET  /stats
  --
  <b>Internal:</b>
  - POST /webhook/gitea
  - Sync job (pulls repo, updates DB)
end note

database "SQLite Database" as DB
note right of DB
  - tools table
  - categories
  - download_stats
  - search_index
end note

component "Gitea Repository\ngitea.brrd.tech/rob/SmartTools-Registry" as GiteaRepo
note right of GiteaRepo
  /tools/
    - summarize.yaml
    - translate.yaml
    - code-review.yaml
  /index.json (auto-generated)
  /categories.json
end note

Users --> CLI
Users --> WebUI

CLI --> APIServer : HTTPS
WebUI --> APIServer : HTTPS

APIServer --> DB : reads/writes
APIServer --> GiteaRepo : syncs with

ToolPublisher --> GiteaRepo : PR for new tools
GiteaRepo --> APIServer : webhook events

@enduml