Overview
LiteClient is a lightweight REST API client that runs entirely within VS Code. All data persists locally with no external services or telemetry. The extension follows VS Code’s extension architecture patterns and leverages native platform capabilities.Three-Tier Architecture
The extension is organized into three distinct layers:1. Extension Module
Runs in the VS Code extension host process (Node.js environment). Responsibilities:- Business logic for collections, environments, history
- HTTP request execution with Node.js capabilities
- File I/O and data persistence
- Cookie management and OAuth2 flows
- Command registration and handling
- Services (business logic)
- Commands (user-invokable actions)
- Providers (webview lifecycle management)
- Storage (JSON file persistence)
2. Message Protocol
Typed communication layer between extension and webview. Features:- Type-safe message definitions
- Bidirectional communication
- Request/response patterns
- State synchronization
- Request execution (
send-request) - Response delivery (
response) - State updates (
collections-list,environments-list,history-list) - User actions (create, update, delete operations)
3. Webview Module
Runs in a webview context (browser-like environment). Responsibilities:- User interface rendering
- Form input and validation
- Response visualization
- Request/response editing
- Lit web components
- CodeMirror 6 for code editing
- Native HTML/CSS for performance
Extension Module Architecture
Services Layer
The services layer encapsulates all business logic:- CollectionService
- EnvironmentService
- HistoryService
- HttpRequestService
- OAuth2TokenService
- SettingsService
File:
collectionService.tsResponsibilities:- CRUD operations for collections, folders, and requests
- Postman Collection v2.1 import/export
- Nested folder hierarchy management
- Request metadata persistence
collections.jsonService Patterns
All services follow consistent design patterns:- Constructor injection: StorageService injected via constructor
- Async/await: All I/O operations are asynchronous
- Error handling: Descriptive errors thrown for invalid operations
- Single responsibility: Each service owns a specific domain
Providers Layer
Providers manage webview lifecycle and message routing:Manages the sidebar webview with Collections, Environments, and History tabs.Lifecycle:
- Creates webview on sidebar activation
- Loads HTML/CSS/JS for sidebar UI
- Routes messages between webview and services
- Handles state synchronization
Creates and manages request editor panels (custom editor for
.lcreq files).Lifecycle:- Opens panel when
.lcreqfile is opened - Loads request data from file
- Handles OAuth2 flows via URI handler
- Saves request changes back to file
Manages the cookie manager webview panel.Lifecycle:
- Opens on command invocation
- Displays all cookies grouped by domain
- Handles cookie editing and deletion
Commands Layer
Commands are user-invokable actions registered inpackage.json:
| File | Commands |
|---|---|
collectionCommands.ts | Collection CRUD, import/export |
environmentCommands.ts | Environment and variable operations |
historyCommands.ts | History access and management |
requestCommands.ts | New request creation |
cookieCommands.ts | Cookie management commands |
Webview Architecture
Request Editor Components
The request editor is built with Lit web components:- lc-url-bar: URL input with HTTP method selector
- lc-tabs: Tab navigation for request sections
- lc-headers-table: Key-value editor for headers
- lc-body-panel: Request body editor with format support
- lc-auth-panel: Authentication configuration (OAuth2, Bearer, Basic)
- lc-form-data-editor: Multipart form-data with file uploads
- lc-variable-autocomplete: Environment variable autocomplete (
{{var}}) - lc-response-view: Response display with syntax highlighting
- lc-cookies-table: Response cookies viewer
- lc-status-bar: Response status, timing, size
- lc-request-meta: Request metadata (name, description)
Sidebar Components
- lc-sidebar-panel: Main container with tabs
- lc-collection-tree: Hierarchical collection browser
- lc-env-switcher: Environment selector dropdown
- lc-environment-list: Environment and variable management
- lc-history-list: Day-grouped request history
- lc-cookie-manager: Cookie management interface
Shared Components
Shared across request editor and sidebar:- models.ts: TypeScript data models (Environment, Collection, Request, etc.)
- messages.ts: Typed message definitions for extension communication
- variableSubstitution.ts:
{{variableName}}substitution logic - variableResolver.ts: Centralized variable resolution with layered precedence
Data Storage
Storage Architecture
LiteClient uses a JSON file-based storage system:Storage Scopes
- Global Storage
- Workspace Storage
Location: VS Code’s
globalStorageUriCharacteristics:- Private to the user
- Not stored in project repository
- Available across all workspaces
- Platform-specific location
StorageService
Provides atomic file operations with corruption recovery:- Atomic writes (write to temp file, then rename)
- Backup on corruption detection
- JSON schema validation
- Error recovery
Request Execution Flow
The complete flow from user action to response display:Variable Resolution Order
Variables follow a layered precedence (narrowest scope wins):- Globals - Shared across all requests
- Collection - Available to all requests in a collection
- Environment - Scoped to selected environment
Only enabled variables are resolved. Disabled variables are ignored during substitution.
Extension Initialization
Startup sequence when VS Code activates the extension:extension.activate()called- Create
StorageService(determines scope from settings) - Instantiate all services with
StorageServiceinjection - Register
SidebarProviderfor sidebar webview - Register
RequestPanelManagerfor.lcreqcustom editor - Register
CookieManagerProviderfor cookie manager panel - Register URI handler for OAuth2 callbacks
- Register all commands with
CommandDependencies - Extension ready for user interaction
Performance Considerations
- Lazy loading: Webviews created only when needed
- Efficient messaging: Only changed state synchronized
- JSON streaming: Large responses streamed to webview
- CodeMirror: Virtual scrolling for large documents
- Indexed lookups: Fast collection/environment retrieval
Security Model
- Local-only: No external network calls except user requests
- No telemetry: Zero tracking or analytics
- SecretStorage: OAuth tokens stored in VS Code’s encrypted storage
- Sandboxed webviews: Isolated execution context
- Script sandboxing: Pre-request/test scripts run in Node.js
vmsandbox