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