@@ -16,62 +16,30 @@ services/gateway/
16
16
├── src/ # Source code
17
17
│ ├── index.ts # CLI entry point and command registration
18
18
│ ├── commands/ # Command implementations
19
- │ │ ├── index.ts # Command exports
20
19
│ │ ├── login.ts # Authentication with cloud.deploystack.io
21
- │ │ ├── logout.ts # Clear local credentials
22
20
│ │ ├── start.ts # Start the gateway server
23
- │ │ ├── stop.ts # Stop the gateway server
24
- │ │ ├── status.ts # Show gateway status
25
- │ │ ├── mcp.ts # MCP server management and tool discovery
26
- │ │ └── config.ts # Manage local configuration
21
+ │ │ ├── refresh.ts # Root-level refresh command
22
+ │ │ └── ... # Other CLI commands
27
23
│ ├── core/ # Core business logic
28
24
│ │ ├── auth/ # Authentication handling
29
- │ │ │ ├── client.ts # OAuth and API client
30
- │ │ │ └── storage.ts # Secure credential storage
31
- │ │ ├── server/ # HTTP proxy server
32
- │ │ │ ├── proxy.ts # Request routing and dual-endpoint logic
33
- │ │ │ ├── session-manager.ts # SSE session lifecycle management
34
- │ │ │ └── sse-handler.ts # Server-Sent Events implementation
25
+ │ │ ├── server/ # HTTP proxy server with SSE support
35
26
│ │ ├── process/ # MCP process management
36
- │ │ │ ├── manager.ts # Process lifecycle and stdio communication
37
- │ │ │ └── runtime-state.ts # In-memory process state tracking
38
27
│ │ ├── mcp/ # MCP configuration management
39
- │ │ │ ├── config-service.ts # Team config sync and processing
40
- │ │ │ ├── config-processor.ts # Installation method processing
41
- │ │ │ ├── tool-discovery.ts # MCP server tool discovery
42
- │ │ │ ├── tool-cache.ts # Team-aware tool caching system
43
- │ │ │ └── team-context-manager.ts # Team switching with process lifecycle
44
28
│ │ └── config/ # Configuration utilities
45
- │ │ └── defaults.ts # Default gateway settings
29
+ │ ├── services/ # Shared business services
30
+ │ │ ├── refresh-service.ts # Shared MCP configuration refresh logic
31
+ │ │ ├── server-start-service.ts # Centralized server startup logic
32
+ │ │ └── ... # Other shared services
46
33
│ ├── utils/ # Shared utilities
47
- │ │ ├── tool-discovery-manager.ts # Centralized tool discovery and caching
48
- │ │ ├── state-comparator.ts # Compare expected vs actual running processes
49
- │ │ ├── logger.ts # Centralized logging with chalk
50
- │ │ ├── spinner.ts # Progress indicators with ora
51
- │ │ ├── config.ts # Configuration management
52
- │ │ ├── errors.ts # Custom error types
53
- │ │ └── crypto.ts # Encryption utilities
34
+ │ │ ├── logger.ts # Centralized logging
35
+ │ │ └── ... # Other utilities
54
36
│ └── types/ # TypeScript type definitions
55
- │ ├── index.ts # Main type exports
56
- │ ├── mcp.ts # MCP protocol types
57
- │ └── config.ts # Configuration types
58
- ├── bin/ # Executable entry
59
- │ └── gateway.js # Node.js shebang wrapper
37
+ ├── bin/gateway.js # Executable entry point
60
38
├── dist/ # Compiled JavaScript (gitignored)
61
39
├── tests/ # Test suite
62
- │ ├── unit/ # Unit tests
63
- │ ├── integration/ # Integration tests
64
- │ └── fixtures/ # Test data
65
- ├── scripts/ # Development scripts
66
- │ ├── build.ts # Build script
67
- │ └── release.ts # Release automation
68
- ├── .config/ # Default configurations
69
- │ └── defaults.json # Default gateway settings
70
- ├── package.json # Dependencies and scripts
71
- ├── tsconfig.json # TypeScript configuration
72
- ├── tsup.config.ts # Build configuration
73
- ├── .env.example # Environment variables template
74
- └── README.md # Gateway-specific documentation
40
+ ├── package.json # Dependencies and scripts
41
+ ├── tsconfig.json # TypeScript configuration
42
+ └── README.md # Gateway-specific documentation
75
43
```
76
44
77
45
## Key Design Decisions
@@ -80,6 +48,7 @@ services/gateway/
80
48
The codebase is organized into distinct modules:
81
49
- ** Commands** : User-facing CLI commands
82
50
- ** Core** : Business logic separated by domain
51
+ - ** Services** : Shared business services for cross-command functionality
83
52
- ** Utils** : Reusable utilities and helpers
84
53
85
54
### Process Management
@@ -143,6 +112,11 @@ export function registerLoginCommand(program: Command) {
143
112
- Team-aware tool caching system as detailed in [ Caching System] ( /development/gateway/caching-system )
144
113
- Installation method processing for correct server spawning
145
114
115
+ ** services/** : Shared business services for cross-command functionality
116
+ - ** refresh-service.ts** : Centralized MCP configuration refresh logic used by both ` deploystack refresh ` and ` deploystack mcp --refresh ` commands
117
+ - Eliminates code duplication while maintaining identical behavior across commands
118
+ - Provides consistent error handling and user feedback
119
+
146
120
** utils/** : Shared utilities and centralized services
147
121
- ** tool-discovery-manager.ts** : Centralized tool discovery eliminating code duplication across commands
148
122
- Logging, configuration, and encryption utilities
0 commit comments