# Normogen Deployment to Solaria

## Quick Start

### 1. Deploy to Solaria
```bash
./deploy-to-solaria.sh
```

This script will:
- Push latest changes to git
- Connect to Solaria via SSH
- Clone/update the repository
- Build and start Docker containers
- Show deployment status

### 2. Test All API Endpoints
```bash
./test-api-endpoints.sh
```

This will test:
- Health check
- Authentication (register, login)
- User management (profile, settings)
- Password recovery
- Share management
- Permissions
- Session management

### 3. Check Server Logs
```bash
./check-solaria-logs.sh
```

## Server Information

- **Hostname:** solaria (10.0.10.30)
- **User:** alvaro
- **Remote Directory:** /home/alvaro/normogen
- **API Port:** 8000
- **Base URL:** http://solaria:8000

## What's New in Phase 2.6

### Security Features
✅ **Session Management**
- Track sessions across devices
- Revoke specific or all sessions
- Automatic cleanup

✅ **Audit Logging**
- Log all security events
- Query by user or system-wide
- Track authentication, data access, modifications

✅ **Account Lockout**
- Brute-force protection
- Progressive lockout durations
- Automatic reset on successful login

✅ **Security Headers**
- X-Content-Type-Options: nosniff
- X-Frame-Options: DENY
- X-XSS-Protection: 1; mode=block
- Strict-Transport-Security
- Content-Security-Policy

### New API Endpoints
- `GET /api/sessions` - List all active sessions
- `DELETE /api/sessions/:id` - Revoke specific session
- `DELETE /api/sessions/all` - Revoke all sessions

## Deployment Checklist

- [x] Phase 2.6 implementation complete
- [x] Code compiles successfully
- [x] All changes committed to git
- [x] Deployment scripts created
- [x] API test scripts created
- [ ] Deploy to Solaria
- [ ] Run API tests
- [ ] Verify all endpoints working
- [ ] Check logs for errors

## Troubleshooting

### Connection Issues
```bash
# Test SSH connection
ssh alvaro@solaria

# Check if Docker is running
ssh alvaro@solaria "docker ps"
```

### Container Issues
```bash
# SSH to server
ssh alvaro@solaria

# Check containers
cd ~/normogen/backend
docker-compose ps

# View logs
docker-compose logs backend

# Restart
docker-compose restart
```

### API Not Responding
```bash
# Check if port 8000 is accessible
curl http://solaria:8000/health

# Check firewall
ssh alvaro@solaria "sudo ufw status"
```

## Files Created

1. `deploy-to-solaria.sh` - Automated deployment script
2. `test-api-endpoints.sh` - Comprehensive API testing
3. `check-solaria-logs.sh` - Server log viewer
4. `DEPLOYMENT_GUIDE.md` - Detailed deployment documentation
5. `DEPLOY_README.md` - This file

## Next Steps After Deployment

1. ✅ Verify deployment successful
2. ✅ Test all API endpoints
3. ✅ Check for any errors in logs
4. ⏳ Integrate session management into auth flow
5. ⏳ Implement proper rate limiting
6. ⏳ Add comprehensive tests
7. ⏳ Begin Phase 2.7

## Architecture

```
┌─────────────────────────────────────┐
│         Solaria Server             │
│  ┌──────────────────────────────┐  │
│  │  Docker Compose              │  │
│  │  ┌────────────────────────┐  │  │
│  │  │  Backend Container     │  │  │
│  │  │  - Rust/Axum API       │  │  │
│  │  │  - Port 8000           │  │  │
│  │  └────────────────────────┘  │  │
│  │  ┌────────────────────────┐  │  │
│  │  │  MongoDB Container     │  │  │
│  │  │  - Port 27017          │  │  │
│  │  └────────────────────────┘  │  │
│  └──────────────────────────────┘  │
└─────────────────────────────────────┘
         ↑
         │ SSH + Git
         │
┌────────┴────────┐
│  Local Machine  │
│  - Development  │
│  - Git Push     │
└─────────────────┘
```

## Support

For detailed information:
- See `DEPLOYMENT_GUIDE.md` for comprehensive docs
- See `PHASE_2.6_COMPLETION.md` for implementation details
- See `STATUS.md` for overall project status

Ready to deploy? Run: `./deploy-to-solaria.sh`
