How bobac/nsight-proxy works
Main Components
a. Configuration Loader
– Loads .env variables (NSIGHT_API_KEY, NSIGHT_SERVER)
b. CLI Front-Ends (in cmd/):
• getdata – single‐service JSON fetcher
• fetchall – bulk data fetcher + CSV cache + nested JSON output
c. API Server (in cmd/server) – HTTP server scaffold for future REST endpoints
d. Internal Library (internal/nsight):
• api.go – Go client for N-Able N-Sight Data Extraction API
• types.go – request/response structs
e. Cache Storage (data/ CSV files)
• clients.csv, sites.csv, servers.csv, workstations.csv
f. External N-Able N-Sight API – upstream data source
Out Data Flows & Interactions
a. getdata Flow (no cache):
[getdata CLI]
→ loads config (.env)
→ calls [internal/nsight client]
→ issues HTTP request → [External N-Able API]
← receives JSON → returns JSON to stdout
b. fetchall Flow:
– Without –cache flag:
[fetchall CLI]
→ loads config
→ for each resource (clients, sites, servers, workstations):
→ internal/nsight client → External API → raw JSON
→ transform & append rows → [CSV Cache Storage]
→ read aggregated CSVs → build nested JSON → stdout or file
– With –cache flag:
[fetchall CLI]
→ loads only CSV files from [CSV Cache Storage]
→ build nested JSON → stdout or file
c. API Server (future):
[HTTP Client]
→ HTTP request → [API Server CLI]
→ loads config
→ either:
• call internal/nsight → External API
• read CSV cache → return JSON
→ HTTP response JSON
Architectural Patterns
– Layered Architecture:
• Presentation (CLI & HTTP server)
• Application/Domain (internal/nsight library)
• Infrastructure (HTTP transport to external API, file system CSV cache)
– Separation of Concerns: each CLI has one responsibility, sharing the same client library.
– Cache-Aside Pattern in fetchall (populate CSV cache then read from it).
Relevant Technologies
– Go Modules (go.mod, go.sum)
– Go toolchain (go run, build.sh)
– Environment config (.env, loaded via Go)
– CSV files on disk (ignored by Git via .gitignore)
– Future HTTP server on port 8080 (net/http)
Final Checklist
[ ] Annotation of protocols (HTTP, file I/O)
[ ] Layer separation: Presentation → Domain → Infrastructure