Spaces:
Sleeping
Sleeping
File size: 9,188 Bytes
62ca4d3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | # StrategyStack Deployment Guide
## Customer-Ready Multi-Tenant Platform
This guide explains how to deploy and configure the StrategyStack Recovery, Enrichment & Outreach Platform for production use with Hugging Face Spaces.
---
## β
What's Already Implemented
The platform now includes:
### 1. **OAuth Authentication**
- π Sign in with Hugging Face button
- Automatic user authentication via `gr.OAuthProfile`
- All dashboard panels protected behind authentication
- Unauthenticated users see clear login prompts
### 2. **Per-User Data Isolation**
- Each user's data stored in `/data/users/{username}/`
- Zero data sharing between users
- Customer data ownership model (you don't hold their data)
- Automatic user directory creation on first access
### 3. **Multi-Tenant Architecture**
- Session-based data loading
- Username displayed in all panels
- Sample data for seamless new user onboarding
- Refresh buttons for manual data reloading
### 4. **Data Types Supported**
- Consent events (consent_events.json)
- Cadence branches (branches.json)
- Diagnostic logs (diagnostics.json)
- Extensible to any JSON-serializable data
---
## π Deployment Steps
### Step 1: Enable Persistent Storage
**CRITICAL**: Hugging Face Spaces must have persistent storage enabled for user data to persist between sessions.
1. Go to your Space: https://huggingface.co/spaces/StrategyStack/README
2. Click on **Settings** tab
3. Scroll to **Storage** section
4. Enable **Persistent storage**
5. Select storage size (recommended: 20GB minimum for multi-tenant use)
6. Save changes
**Note**: Persistent storage is mounted at `/data` and persists across Space restarts.
### Step 2: Configure Space Secrets (Optional)
If your application needs API keys for external services:
1. Go to **Settings** tab
2. Scroll to **Variables and secrets** section
3. Add secrets:
- `LINKEDIN_API_KEY` (if using LinkedIn integration)
- `TWILIO_API_KEY` (if using Twilio integration)
- `SALESFORCE_API_KEY` (if using Salesforce integration)
- Any other API keys your agents require
4. Access in code:
```python
import os
linkedin_key = os.getenv('LINKEDIN_API_KEY')
```
### Step 3: Verify OAuth Configuration
The OAuth setup is already complete:
- β
README.md has `hf_oauth: true` in metadata (line 9)
- β
app.py has `gr.LoginButton()` component
- β
All functions accept `gr.OAuthProfile` parameter
No additional OAuth configuration needed!
### Step 4: Test Multi-User Access
1. Open the Space: https://huggingface.co/spaces/StrategyStack/README
2. Click **Sign in with Hugging Face**
3. Verify you see:
- Your username displayed in panels
- Sample data (since you're a new user)
- All four dashboard tabs accessible
4. Test with a second account:
- Sign out
- Sign in with different HF account
- Verify data is separate from first account
---
## π Monitoring & Operations
### Viewing Logs
1. Go to Space page
2. Click on **Logs** dropdown (top right)
3. Select:
- **Build** - See build logs
- **Container** - See runtime application logs
### Space Status
- π’ **Running** - Space is live and accepting users
- π΅ **Building** - Space is being rebuilt after code changes
- π΄ **Runtime Error** - Check container logs for errors
### Restarting the Space
If you need to restart:
1. Go to **Settings** tab
2. Scroll to **Sleep time settings**
3. Click **Restart Space**
**Note**: Persistent storage data survives restarts!
---
## πΎ Data Management
### User Data Structure
```
/data/
βββ users/
βββ username1/
β βββ consent_events.json
β βββ branches.json
β βββ diagnostics.json
βββ username2/
β βββ consent_events.json
β βββ branches.json
β βββ diagnostics.json
βββ ...
```
### Accessing User Data
The app provides helper functions:
```python
# Load user data
user_events = load_user_data(username, "consent_events")
# Save user data
save_user_data(username, "consent_events", data)
# Get user directory
user_dir = get_user_dir(username)
```
### Backup Strategy
**Important**: While persistent storage is durable, implement regular backups:
1. **Option A - Manual Backup**:
- Use Hugging Face Hub's file browser
- Download `/data` directory contents
- Store securely off-platform
2. **Option B - Automated Backup** (Future Enhancement):
- Add scheduled backup function
- Export to external cloud storage
- Implement via Space cron or external scheduler
---
## βοΈ Configuration Options
### Customizing Data Storage Location
Edit `app.py` line 9:
```python
DATA_DIR = Path("/data") # Change if needed
```
### Adding New Data Types
1. Define new data structure (JSON-serializable)
2. Use existing functions:
```python
# Save new data type
save_user_data(username, "campaigns", campaign_data)
# Load new data type
campaigns = load_user_data(username, "campaigns")
```
3. Create UI panel to display/edit
### Customizing Authentication Messages
Edit the authentication check in panel functions (app.py):
```python
if profile is None:
return "Your custom auth message here"
```
---
## π‘οΈ Security Considerations
### Data Isolation
- β
Users cannot access other users' data
- β
File paths use username for isolation
- β
No centralized data storage (privacy by design)
### Authentication
- β
OAuth via Hugging Face (no password management needed)
- β
Profile information provided by HF OAuth
- β
Automatic session management
### API Keys
- β οΈ Store API keys in Space Secrets (not in code)
- β οΈ Never commit API keys to repository
- β οΈ Use environment variables for all sensitive data
---
## π Customer Setup Instructions
Provide these steps to your customers:
### For End Users:
1. **Access the Platform**:
- Visit: https://huggingface.co/spaces/StrategyStack/README
- Click "Sign in with Hugging Face"
- Create free HF account if needed
2. **First Login**:
- You'll see sample data to understand the interface
- Your personal data directory is automatically created
- All your data is isolated from other users
3. **Using the Dashboard**:
- **Consent/Event Audit**: View compliance events
- **Cadence Branching Composer**: Design outreach sequences
- **Live Diagnostics**: Monitor system health
- **Audit Trail Export**: Download compliance reports
4. **Data Refresh**:
- Click "Refresh Data" button in any tab
- Reloads your latest data from storage
### For Administrators:
1. Access Space settings for configuration
2. Monitor logs for user activity
3. Manage Space resources (storage, compute)
4. Configure API keys for integrations
---
## π Troubleshooting
### Issue: "Authentication Required" message persists
**Solution**:
- Ensure you've clicked "Sign in with Hugging Face"
- Check browser cookies are enabled
- Try hard refresh (Cmd+Shift+R / Ctrl+Shift+R)
### Issue: Data not persisting between sessions
**Solution**:
- Verify persistent storage is enabled in Space settings
- Check storage quota hasn't been exceeded
- Review container logs for write errors
### Issue: Space shows "Runtime Error"
**Solution**:
1. Click on "Logs" β "Container"
2. Look for Python errors or exceptions
3. Check if `/data` directory is accessible
4. Verify all dependencies in requirements.txt
### Issue: Slow performance
**Solution**:
- Upgrade Space hardware tier in Settings
- Optimize data loading (lazy loading)
- Implement caching for frequently accessed data
---
## π Next Steps / Future Enhancements
### Phase 1: Enhanced Data Management
- [ ] CSV export functionality
- [ ] Data import from external sources
- [ ] Bulk operations for large datasets
- [ ] Data visualization charts
### Phase 2: Integration Capabilities
- [ ] Connect actual LinkedIn API
- [ ] Twilio SMS integration
- [ ] Salesforce sync
- [ ] Email campaign management
### Phase 3: Advanced Features
- [ ] Team collaboration (share data with team members)
- [ ] Role-based access control
- [ ] Automated backup to cloud storage
- [ ] Advanced analytics dashboard
### Phase 4: Enterprise Features
- [ ] SSO integration
- [ ] Compliance certifications (SOC 2, GDPR)
- [ ] White-label branding
- [ ] Custom domain support
---
## π Support
For technical support:
- **Documentation**: See README.md for API documentation
- **Issues**: Report bugs via Hugging Face Space discussions
- **Questions**: Contact via Space community tab
---
## π Summary
Your StrategyStack platform is now **customer-ready** with:
β
**Zero-config deployment** - Works out of the box on HF Spaces
β
**Secure authentication** - OAuth via Hugging Face
β
**Data privacy** - Per-user isolated storage
β
**Multi-tenant** - Unlimited users, isolated data
β
**No external dependencies** - Everything on HF Spaces
β
**Persistent storage** - Data survives restarts
β
**Compliance-ready** - Full audit trails
Just enable persistent storage and you're ready to onboard customers!
---
**Last Updated**: 2025-01-06
**Platform Version**: 1.0.0 (OAuth-enabled)
**Hugging Face Spaces**: β
Production Ready |