How adamlounds/nightscout-go works
Main Components
a) External Clients Layer:
• Nightscout MacOS Menu Bar
• Nightscout-LibreLink-Up
• Scoutnight
• Nightguard iOS app
• Other API consumers
b) API Layer:
• API v1 endpoints (controllers/api1.go)
• Authentication middleware (controllers/api1_auth_middleware.go)
c) Core Service Layer:
• Entry management
• Treatment management
• Authentication handling
d) Repository/Storage Layer:
• Bucket storage (S3/R2) adapter
• CGM LibreLink-Up integration
• Nightscout compatibility layer
┌─────────────────────────────────────────────────────────────┐
• External Clients │
• ┘
• ↓ HTTPS
┌─────────────────────────────────────────────────────────────┐
• API Layer (v1) │
• ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │
• Entry APIs │ │Treatment APIs│ │Authentication APIs│ │
• ┘ └──────────────┘ └──────────────────┘ │
• ┘
• ↓
┌─────────────────────────────────────────────────────────────┐
• Service Layer │
• ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │
• Entry Service│ │Treatment Svc │ │ Auth Service │ │
• ┘ └──────────────┘ └──────────────────┘ │
• ┘
• ↓
┌─────────────────────────────────────────────────────────────┐
• Repository Layer │
• ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │
• Bucket Store │ │CGM LibreLink │ │ Nightscout │ │
• (S3/R2) │ │ Up │ │ Repository │ │
• ┘ └──────────────┘ └──────────────────┘ │
• ┘
Important Architectural Patterns to Highlight
a) Repository Pattern:
• Clear separation between storage implementations
• Pluggable nature of storage adapters
b) Middleware Chain:
• Authentication flow
• How API requests are processed
Data Flow Indicators
• How data flows from CGM LibreLink-Up to storage
• How clients retrieve data through the API
• How authentication is verified for each request
Technical Details to Note
• Relationship between the cmd/server component and other layers
• Where configuration (config/config.go) affects different components
• Where tests exist (particularly for entry_bucket_repository_test.go)