@startuml
!define RECTANGLE rectangle
!define COMPONENT component

skinparam component {
  BackgroundColor<<External>> #E6F3FF
  BackgroundColor<<Internal>> #F0F0F0
  BackgroundColor<<User>> #E8F5E8
  BorderColor #333333
  ArrowColor #333333
  FontSize 12
}

title SmartTools Registry Architecture

package "Users" <<User>> {
  actor "CLI User" as cli_user
  actor "Web User" as web_user
  actor "Tool Publisher" as tool_publisher
}

note right of tool_publisher
  Gitea account required
end note

package "Client Interfaces" <<User>> {
  component "smarttools CLI" as cli
  component "Web UI (future)" as web_ui
}

note right of cli
  • registry search
  • registry install
  • registry publish
  • registry browse (TUI)
end note

note right of web_ui
  • Browse tools
  • Search
  • View tool details
end note

package "REGISTRY API SERVER" <<Internal>> {
  component "Flask/FastAPI" as server
  component "Endpoints" as endpoints
  component "Internal" as internal
}

note right of server
  Hosted at: registry.smarttools.dev
  (or gitea.brrd.tech/api/registry)
end note

endpoints : GET  /tools
endpoints : GET  /tools/search?q=...
endpoints : GET  /tools/{name}
endpoints : GET  /tools/{name}/download
endpoints : POST /tools
endpoints : GET  /categories
endpoints : GET  /stats

internal : POST /webhook/gitea
internal : Sync job

component "SQLite Database" as database <<Internal>> {
  component "Database Schema" as db_schema
}

db_schema : tools table
db_schema : categories
db_schema : download_stats
db_schema : search_index

component "Gitea Repository" as gitea_repo <<External>> {
  component "Repository Structure" as repo_structure
}

repo_structure : gitea.brrd.tech/rob/SmartTools-Registry
repo_structure : /tools/
repo_structure :   ├── summarize.yaml
repo_structure :   ├── translate.yaml
repo_structure :   └── code-review.yaml
repo_structure : /index.json  (auto-generated)
repo_structure : /categories.json

' Connections
cli_user --> cli : uses
web_user --> web_ui : uses

cli --> api_server : HTTPS
web_ui --> api_server : HTTPS

api_server --> database : reads/writes
api_server --> gitea_repo : syncs with

tool_publisher --> gitea_repo : submits PR
gitea_repo --> api_server : webhook events

@enduml