Sasha Studio - Claude Code Integration Architecture
Overview
This document defines the complete architecture for how Sasha Studio integrates with Claude Code, establishing clear separation between user projects, shared documentation, and Claude's metadata.
Core Philosophy
The Web UI is just a view of the Claude Code file system
Sasha Studio doesn't manage Claude Code - it leverages Claude Code's natural project and session management while providing a user-friendly interface and centralized documentation system.
Architecture Principles
1. Separation of Concerns
- User Projects: Actual working directories in
/home/nodejs/projects/(e.g.,company-search,legal) - Shared Documentation: Centralized in
/home/nodejs/all-project-files/docs/ - Claude Metadata: Automatically managed by Claude in
/home/nodejs/.claude/projects/
2. Claude Code Integration
- Claude Code works in directories we specify via
cwd - Claude Code creates its own session metadata automatically
- UI observes and displays what Claude has created
3. Multi-Project Architecture
Each user project has its own directory and Claude sessions. Project switching changes the current working directory for Claude Code to the specific project directory.
Directory Structure
/home/nodejs/ # Persistent volume root
βββ projects/ # User Projects (WE manage)
β βββ company-search/ # First project (from onboarding)
β β βββ docs/ # Project-specific files
β β βββ CLAUDE.md # Project context
β β βββ [user files]
β βββ [other-projects]/ # Additional user projects
β
βββ all-project-files/ # Shared Documentation (WE manage)
β βββ docs/ # Central docs location
β β βββ guides/ # User guides
β β βββ specialists/ # AI specialists/personas
β β βββ private/ # System guides/specialists
β βββ uploads/ # User uploaded files
β βββ converted/ # Converted documents
β
βββ .claude/ # Claude Code Metadata (CLAUDE manages)
βββ projects/ # Session storage
β βββ -home-nodejs-projects-company-search/ # Encoded project paths
β β βββ session1.jsonl
β β βββ session2.jsonl
β βββ -home-nodejs-projects-legal/
βββ config files...
Component Responsibilities
Projects Service (projects.js)
Purpose: Bridge between our project directories and Claude's metadata
Current Implementation :
- Reads actual project directories from
/home/nodejs/projects/ - Maps each to Claude's encoded metadata path
- Returns projects with both
fullPath(actual) andpath(encoded)
Key Functions:
getProjects(): Scans/home/nodejs/projects/and matches to Claude sessionsencodeProjectPath(): Converts/home/nodejs/projects/fooβ-home-nodejs-projects-foo
Workspace Manager (workspace-manager.js)
Purpose: Create initial project structure after onboarding
Current Status: Mostly correct
- Creates projects in
/home/nodejs/projects/ - Generates initial CLAUDE.md with project context
Functions:
setupOrganizationWorkspace(): Createscompany-searchproject directorycreateDocumentIndex(): Manages uploaded document organization
Chat Interface (ChatInterface.jsx)
Purpose: Send messages to Claude with correct working directory
Current Implementation :
// When sending message to Claude
const options = {
projectPath: selectedProject.path, // Claude's encoded path
cwd: selectedProject.fullPath, // Actual directory path
// ... other options
};
Key Insight: cwd parameter becomes the working directory for Claude CLI
Claude CLI Service (claude-cli.js)
Purpose: Execute Claude Code with specified working directory
Current Implementation :
let spawnOptions = {
cwd: workingDir, // This comes from the cwd parameter
stdio: ['pipe', 'pipe', 'pipe'],
env: { ...processEnv, PATH: process.env.PATH }
};
Content Reader (content-reader.js)
Purpose: Read guides and specialists for UI display
Current Status: COMPLETED
- Reads from
/home/nodejs/all-project-files/docs(correct) - Serves shared documentation to UI panels
Data Flow
Project Creation Flow
- User completes onboarding
workspace-manager.jscreates/home/nodejs/projects/company-search/- Initial CLAUDE.md created with project context
- UI automatically shows new project
Message Sending Flow
- User types message in UI
ChatInterface.jsxsends message withcwd: selectedProject.fullPathclaude-cli.jsspawns Claude CLI with that working directory- Claude Code works in
/home/nodejs/projects/company-search/ - Claude Code creates session metadata in
.claude/projects/{encoded-path}/
Project Discovery Flow
- UI loads, calls
/api/projects projects.jsscans/home/nodejs/projects/for directories- For each directory, looks up Claude sessions using encoded path
- Returns combined project + session data to UI
Documentation Loading Flow
- UI requests guides/specialists
content-reader.jsreads from/home/nodejs/all-project-files/docs/- Returns structured data to UI panels
Docker Integration
Volume Strategy
- Single Volume:
/home/nodejsmounted to persist all user data - Build-time Docs:
/app/deployed-md-files/copied during image build - Runtime Copy: On first startup, copy to
/home/nodejs/all-project-files/
Docker Development (docker-dev.sh)
- Named Volume:
sasha-dev-homefor development persistence - Clean Starts: Volume recreated each run for testing
- Volume Mapping: Local development can map to different paths
Docker Entrypoint (docker-entrypoint.sh)
- Create required directories (projects, all-project-files)
- Copy documentation if not exists to central location
- Set up Claude CLI symlinks for compatibility
- Don't interfere with Claude's metadata
Implementation Changes COMPLETED
1. Legacy Workspace Code Removal
Files Updated: All workspace-related code removed
Key Changes Made:
- Removed workspace directory creation from
docker-entrypoint.sh - Removed workspace special cases from
server/projects.js - Updated all file handling to use standard project extraction
- Updated paths to use
/home/nodejs/all-project-files/docs/for shared content
2. Docker Configuration Cleanup COMPLETED
Files: claudecodeui/docker-entrypoint.sh, Dockerfile.sliplane
Changes Made:
- Removed workspace directory and symlink creation
- Removed redundant
.claudedirectory copy from Dockerfile - Removed unused environment variables (
UPLOAD_FOLDER) - Simplified entrypoint to basic directory setup only
3. JavaScript Code Updates COMPLETED
Files: Multiple server-side files
Changes Made:
- Removed all workspace special case handling
- Updated project resolution to use
/home/nodejs/projects/ - Updated shared documentation paths to
/home/nodejs/all-project-files/ - Simplified App.jsx project selection logic
4. Current Clean Architecture COMPLETED
Final Directory Structure:
/home/nodejs/
βββ projects/ # User Projects
β βββ company-search/ # Individual projects
β βββ legal/ # Each with own sessions
βββ all-project-files/ # Shared Documentation
β βββ docs/ # Centralized guides & specialists
β β βββ guides/
β β βββ specialists/
β β βββ uploads/ # File uploads
β βββ html-static/ # Generated documentation
βββ .claude/ # Claude Metadata
βββ projects/ # Session storage per project
Testing Strategy
1. Project Creation
- Onboarding creates project in
/home/nodejs/projects/company-search/ - Project appears in UI sidebar
- Can send messages in project context
2. Documentation Loading
- Guides panel loads from
/home/nodejs/all-project-files/docs/guides/ - Specialists panel loads from
/home/nodejs/all-project-files/docs/specialists/ - File manager shows shared files
3. Session Management
- Messages create Claude sessions automatically
- Sessions appear in UI for correct project
- Project switching changes Claude's working directory
4. Docker Testing
- Fresh container startup works
- Documentation copied to correct location
- Volume persistence across restarts
- Clean development starts
Migration Path
Phase 1: Fix Documentation Loading
- Update
content-reader.jsto read from correct location - Update
docker-entrypoint.shto copy docs correctly - Test guides/specialists panels
Phase 2: Clean Docker Development
- Update
docker-dev.shvolume management - Test fresh container starts
- Verify clean state between runs
Phase 3: Verification
- Full integration testing
- Documentation updates
- Team training
Success Criteria
Technical
- All UI panels load correctly
- Project switching works seamlessly
- Claude Code sessions created in correct metadata locations
- Documentation persists across container restarts
- Development workflow is clean and reliable
User Experience
- No visible changes to end users
- Faster, more reliable operation
- Clear separation between projects
- Consistent behavior across environments
Rollback Plan
If issues arise:
- Revert
content-reader.jschanges - Restore old
docker-entrypoint.shlogic - Use old volume mounting approach
- Document lessons learned
Future Considerations
Multiple Project Types
- Support for different project templates
- Project creation from UI
- Import existing projects
Documentation Management
- User-editable guides
- Project-specific documentation
- Documentation versioning
Advanced Claude Integration
- Custom Claude configurations per project
- Project-specific tools and permissions
- Enhanced session management
Document Status: Draft
Last Updated: 2025-08-23
Next Review: After implementation