How abhiraj-ku/icli works
iCli is a read-only PostgreSQL advisor CLI. Its main command connects to PostgreSQL, selects expensive statements, explains and analyzes their plans, then reports unused indexes and missing foreign-key indexes; a separate report command collects health metrics. The README documents all major capabilities, while sampled source confirms the main analysis, reporting, and health paths. The update command is documented in source but is separate from database analysis.
Main entry points: main.go Command routing · collector.go Health metrics collection · connect.go DB connection pool · stats.go Expensive query stats
Components 16
CLI orchestration
- Command routing
cmd/icli/main.go
Query and index analysis
- DB connection pool
internals/db/connect.go - Expensive query stats
internals/db/stats.go - Plan retrieval
internals/db/explain.go - Plan traversal
internals/analyzer/engine.go - Bottleneck rules
internals/analyzer/rules.go - Unused index scan
internals/db/stats.go - Missing FK index scan
internals/db/stats.go
Health reporting
- Health metrics collection
internals/health/collector.go - Health report data
internals/health/types.go
Terminal presentation
- Analysis output
internals/report/printer.go - Health output
internals/report/health.go
Other components
- CLI user
- PostgreSQL
- Terminal
- Release update service
Connections 21
- CLI user → Command routing: runs command
- Command routing → DB connection pool: opens pool
- DB connection pool → PostgreSQL: connects
- Command routing → Expensive query stats: fetches top queries
- Expensive query stats → PostgreSQL: reads statistics
- Command routing → Plan retrieval: requests plans
- Plan retrieval → PostgreSQL: runs EXPLAIN
- Command routing → Plan traversal: analyzes plans
- Plan traversal → Bottleneck rules: evaluates nodes
- Command routing → Unused index scan: fetches unused indexes
- Unused index scan → PostgreSQL: reads index stats
- Command routing → Missing FK index scan: fetches missing indexes
- Missing FK index scan → PostgreSQL: reads catalog
- Command routing → Analysis output: prints findings
- Analysis output → Terminal: renders output
- Command routing → Health metrics collection: fetches health report
- Health metrics collection → PostgreSQL: reads health metrics
- Health metrics collection → Health report data: populates report
- Command routing → Health output: renders report
- Health output → Terminal: prints report
- CLI user → Release update service: requests update