This file contains coordination information between Developer 1 (TypeScript Configuration & ChimeraX Integration) and Developer 3 (Frontend Components & Integration).
-
TypeScript configuration fixes:
- Updated tsconfig.json with proper configurations and path aliases
- Updated Express type definitions to handle custom properties
- Fixed route handler types in api.ts
-
ChimeraX integration implementation:
- Verified existing ChimeraX Process Manager implementation
- Verified existing Command Service implementation
- Verified existing ChimeraX Controller implementation
- Created enhanced dev-server.js for testing ChimeraX connectivity
- Wait for Dev3's WebSocket implementation to integrate with ChimeraX events
-
Frontend Environment Configuration
- Updated vite.config.ts with proper proxy configuration for API and WebSocket
- Added HMR support and path aliases
- Configured build optimization settings
-
API Client Implementation
- Created enhanced API client with authentication header management
- Implemented request/response interceptors
- Added token refresh logic and retry capabilities
- Implemented error handling
-
Authentication Components
- Created LoginForm component
- Created RegisterForm component
- Implemented ProtectedRoute for secured pages
- Created AuthContext for state management
- Implemented useAuth hook
-
Molecular Viewer Components
- Enhanced MolecularViewer with advanced rendering capabilities
- Implemented multiple representation types (ball-and-stick, sphere, stick, etc.)
- Added color schemes (element, residue, chain, b-factor)
- Created ViewerControls component for adjusting visualization settings
-
Session Management Components
- Implemented SessionControls for session creation, refresh, and closing
- Created SessionList for browsing and selecting available sessions
- Added proper status indicators and session metadata display
-
WebSocket Service Implementation
- Created robust WebSocket service with reconnection logic
- Implemented message queuing for offline/disconnected periods
- Added support for authentication and session-based connections
- Defined comprehensive WebSocket message types aligned with ChimeraX events
- Additional Context Providers and Hooks for remaining functionality
- WebSocket integration with backend ChimeraX events
- End-to-end testing of critical workflows
- The WebSocketMessage interface in
/src/server/types/websocket.ts
already has a payload property marked as optional - ChimeraX process management has been implemented and can emit events when:
- A ChimeraX process starts or stops
- A ChimeraX command completes
- A ChimeraX process experiences an error
- Dev3 should implement WebSocket server initialization and message handling
For integration with the WebSocket system, the following ChimeraX-related events are available:
CHIMERAX_STARTED
: When a ChimeraX process is successfully startedCHIMERAX_ERROR
: When a ChimeraX process encounters an errorCHIMERAX_TERMINATED
: When a ChimeraX process is terminatedOPERATION_STARTED
: When a long-running ChimeraX operation beginsOPERATION_PROGRESS
: For progress updates during operationsOPERATION_COMPLETED
: When an operation completes successfullyOPERATION_FAILED
: When an operation fails
- ChimeraX controllers and command services are implemented
- Dev3 should ensure WebSocket connections can be associated with specific ChimeraX sessions
- A development server has been created at
/dev-server.js
for testing ChimeraX connectivity - It provides endpoints for:
- Starting/stopping ChimeraX processes
- Checking ChimeraX status
- Sending commands to ChimeraX
- Simulating session creation/termination
For the MolecularViewer component:
- What format will the atom/bond data be in when retrieved from the backend?
- Will additional metadata (residues, chains, secondary structure) be available?
- Is there a limit to the size of molecules that can be rendered?
I would appreciate information about:
- What session metadata is available from the backend?
- Are there specific session lifecycle events I should listen for?
- How should the frontend handle session timeouts or disconnections?
- What is the expected format for ChimeraX commands sent via the API?
- How should the frontend handle asynchronous results from ChimeraX operations?
- Are there any planned backend endpoints I should be aware of for the next implementation phase?
- What WebSocket message types will you need from the ChimeraX integration?
- Do you have specific requirements for the WebSocket authentication flow?
- How should ChimeraX events be propagated to connected clients?
I've implemented a WebSocket service that supports all the ChimeraX event types you specified (CHIMERAX_STARTED
, CHIMERAX_ERROR
, etc.). Additionally, I've defined the following message types that would be useful:
- Session events:
SESSION_CREATED
,SESSION_UPDATED
,SESSION_CLOSED
,SESSION_EXPIRED
- Structure events:
STRUCTURE_LOADED
,STRUCTURE_MODIFIED
,STRUCTURE_REMOVED
- Command events:
COMMAND_SENT
,COMMAND_RESULT
- Connection events:
CONNECTION_ESTABLISHED
,CONNECTION_ERROR
,CONNECTION_CLOSED
The WebSocket service now supports the following authentication flow:
- Connect to WebSocket server with session ID and/or auth token as query parameters
- If authenticated with token, send an
AUTH_REQUEST
message after connection - Server responds with
AUTH_SUCCESS
orAUTH_FAILURE
- All subsequent messages include the session ID for proper routing
I suggest the following approach for event propagation:
- Each WebSocket connection should be associated with a specific session
- ChimeraX events should be sent only to clients subscribed to that session
- For long-running operations, progress updates should be sent periodically
- Critical errors should be broadcast to all connected clients of affected sessions
- The WebSocket service includes a subscription mechanism for components to listen for specific event types
-
Atom/Bond Data Format: The atom/bond data is returned in a structured JSON format from the backend:
interface AtomData { id: number; element: string; name: string; serial: number; x: number; y: number; z: number; residue: string; residueId: number; chain: string; bfactor?: number; occupancy?: number; isHet?: boolean; } interface BondData { id: number; atom1: number; atom2: number; order: number; type?: string; length?: number; }
-
Additional Metadata: Yes, additional metadata is available through the API:
interface ResidueData { id: number; name: string; number: number; insertionCode?: string; chain: string; secondaryStructure?: string; atoms: number[]; } interface ChainData { id: string; name: string; residueCount: number; atomCount: number; description?: string; residues: number[]; } interface StructureMetadata { id: string; modelId: number; name: string; type: StructureType; source?: string; resolution?: number; chains?: number; residues?: number; atoms?: number; bonds?: number; created: Date; }
-
Size Limits: There are practical limits based on browser performance:
- Optimal performance: Up to ~100,000 atoms
- Maximum recommended: ~500,000 atoms
- Above this limit, we recommend using simplified representations like ribbon/cartoon
- The backend has a streaming mechanism for larger structures that can be used with WebGL instancing for better performance
-
Session Metadata: Available session metadata includes:
interface Session { id: string; userId: string; processId: string; status: 'initializing' | 'ready' | 'busy' | 'error' | 'terminated'; created: Date; lastActive: Date; port?: number; structures?: StructureMetadata[]; metadata?: { title?: string; description?: string; tags?: string[]; customFields?: Record<string, any>; }; }
-
Session Lifecycle Events: Important session lifecycle events to listen for:
SESSION_CREATED
: When a new session is createdSESSION_STATUS_CHANGED
: When session status changesSESSION_ACTIVITY_UPDATED
: When session activity timestamp is updatedSESSION_TERMINATED
: When a session is terminatedSESSION_TIMEOUT_WARNING
: When a session is approaching inactivity timeoutSESSION_ERROR
: When an error occurs in the session
-
Session Timeout Handling: The frontend should:
- Send heartbeat messages every 30 seconds to keep the session active
- Listen for
SESSION_TIMEOUT_WARNING
and prompt the user to continue - If disconnected, attempt to reconnect and restore the session
- If the session expired, offer to create a new session and recover data if possible
- Sessions timeout after 30 minutes of inactivity by default
-
ChimeraX Command Format: Commands are sent as plain strings in the same format as ChimeraX command line:
// Example API call const result = await api.chimerax.sendCommand({ sessionId: 'session-123', command: 'open 1abc; cartoon; color bychain' });
-
Handling Asynchronous Results: The frontend should:
- Use the WebSocket service to listen for operation events
- For immediate commands, the API returns the result directly
- For long-running operations, track progress using the operation ID
- Register callbacks for specific operation types
- Use optimistic UI updates where appropriate
- The WebSocket service already has a subscription mechanism that would work well for this
-
Planned Backend Endpoints: The next implementation phase will include:
/api/structures/versions
- Structure version history/api/sessions/snapshots
- Session snapshot management/api/render/movies
- Movie generation from session/api/analysis/
- Structure analysis endpoints/api/projects/
- Project management for organizing sessions
- Dev3 to implement remaining context providers and hooks
- Dev1 to integrate Dev3's WebSocket client with backend ChimeraX events
- Dev3 to implement WebSocket-based real-time updates in frontend components
- Both developers to collaborate on end-to-end testing of the integrated system