Selected Values:{' '}
{value.length > 0 ? value.join(', ') : 'None'}
);
},
};
```
## Database Schema
```
users
├── id (PK)
├── username (unique)
├── email (unique)
├── password (hashed)
├── full_name
├── role (admin/user/viewer)
├── active
└── timestamps
api_keys
├── id (PK)
├── user_id (FK)
├── name
├── key (hashed)
├── key_prefix
├── last_used_at
├── expires_at
└── timestamps
hooks
├── id (PK)
├── user_id (FK)
├── name
├── url
├── method
├── headers (JSON)
├── events (JSON array)
├── active
├── secret
└── timestamps
whatsapp_accounts
├── id (PK)
├── user_id (FK)
├── account_type
├── phone_number (unique)
├── display_name
├── status
├── config (JSON)
└── timestamps
event_logs
├── id (PK)
├── user_id
├── event_type
├── entity_type
├── entity_id
├── action
├── data (JSON)
└── created_at
sessions
├── id (PK)
├── user_id (FK)
├── token (hashed)
├── expires_at
└── timestamps
```
## Architecture Benefits
1. **Clean Separation**: Clear boundaries between storage, auth, and web layers
2. **Testable**: Repository pattern and middleware make testing easy
3. **Extensible**: Easy to add new resources following the established patterns
4. **Secure**: Multi-layered security with authentication, authorization, and ownership
5. **Scalable**: Connection pooling and efficient queries
6. **Maintainable**: Consistent patterns and comprehensive documentation
## Summary
Phase 2 backend is **100% complete** with:
- ✅ Comprehensive tool documentation
- ✅ Complete database layer with models and repositories
- ✅ Full authentication system (JWT + API keys)
- ✅ RESTful API with all CRUD operations
- ✅ Role-based access control
- ✅ Multi-tenant architecture
- ✅ Security and audit logging
Only the frontend UI remains to be implemented to complete Phase 2.