@@ -16,62 +16,30 @@ services/gateway/
1616├── src/ # Source code
1717│ ├── index.ts # CLI entry point and command registration
1818│ ├── commands/ # Command implementations
19- │ │ ├── index.ts # Command exports
2019│ │ ├── login.ts # Authentication with cloud.deploystack.io
21- │ │ ├── logout.ts # Clear local credentials
2220│ │ ├── 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
2723│ ├── core/ # Core business logic
2824│ │ ├── 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
3526│ │ ├── process/ # MCP process management
36- │ │ │ ├── manager.ts # Process lifecycle and stdio communication
37- │ │ │ └── runtime-state.ts # In-memory process state tracking
3827│ │ ├── 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
4428│ │ └── 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
4633│ ├── 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
5436│ └── 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
6038├── dist/ # Compiled JavaScript (gitignored)
6139├── 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
7543```
7644
7745## Key Design Decisions
@@ -80,6 +48,7 @@ services/gateway/
8048The codebase is organized into distinct modules:
8149- ** Commands** : User-facing CLI commands
8250- ** Core** : Business logic separated by domain
51+ - ** Services** : Shared business services for cross-command functionality
8352- ** Utils** : Reusable utilities and helpers
8453
8554### Process Management
@@ -143,6 +112,11 @@ export function registerLoginCommand(program: Command) {
143112- Team-aware tool caching system as detailed in [ Caching System] ( /development/gateway/caching-system )
144113- Installation method processing for correct server spawning
145114
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+
146120** utils/** : Shared utilities and centralized services
147121- ** tool-discovery-manager.ts** : Centralized tool discovery eliminating code duplication across commands
148122- Logging, configuration, and encryption utilities
0 commit comments