203 lines
4.9 KiB
Markdown
203 lines
4.9 KiB
Markdown
# Zanzibar Digital Freezone Portal
|
|
|
|
This is the entry portal for the Zanzibar Digital Freezone platform. It provides a streamlined registration and login interface for digital residents.
|
|
|
|
## Features
|
|
|
|
- **Digital Resident Registration**: Complete multi-step registration process with KYC
|
|
- **Stripe Payment Integration**: Secure payment processing for registration fees
|
|
- **Responsive Design**: Works on desktop and mobile devices
|
|
- **Real-time Validation**: Form validation and error handling
|
|
- **Animated UI**: Smooth transitions and professional interface
|
|
- **Fresh Start**: No form persistence - users start fresh each time for simplicity
|
|
|
|
## What's Included
|
|
|
|
- Resident registration overlay with expandable form
|
|
- Stripe Elements integration for secure payments
|
|
- Form validation and error handling
|
|
- Responsive Bootstrap-based design
|
|
- WASM-based Yew frontend
|
|
|
|
## What's Removed
|
|
|
|
This portal is a stripped-down version of the main platform that only includes:
|
|
- Resident registration components
|
|
- Stripe payment integration
|
|
- Essential models and services
|
|
|
|
Removed components:
|
|
- Company registration
|
|
- Treasury dashboard
|
|
- Accounting system
|
|
- Business management features
|
|
- Admin panels
|
|
- Full platform navigation
|
|
|
|
## Quick Setup
|
|
|
|
### 1. Set Up Portal Server
|
|
First, make sure the portal-server is running with API keys configured:
|
|
|
|
```bash
|
|
# In the portal-server directory
|
|
cd ../portal-server
|
|
cp .env.example .env
|
|
# Edit .env file with your API keys (see portal-server README)
|
|
cargo run -- --from-env --verbose
|
|
```
|
|
|
|
### 2. Configure Portal Client
|
|
Set up the API key for the portal client:
|
|
|
|
```bash
|
|
# In the portal directory
|
|
# The .env file is already created with a default API key
|
|
cat .env
|
|
```
|
|
|
|
Make sure the `PORTAL_API_KEY` in the portal `.env` matches one of the `API_KEYS` in the portal-server `.env`.
|
|
|
|
### 3. Run the Portal
|
|
```bash
|
|
# Install trunk if you haven't already
|
|
cargo install trunk
|
|
|
|
# Load environment variables and serve
|
|
source .env && trunk serve
|
|
```
|
|
|
|
## Building and Running
|
|
|
|
### Development Mode
|
|
```bash
|
|
# Load environment variables and serve for development
|
|
source .env && trunk serve
|
|
|
|
# Or set the API key inline
|
|
PORTAL_API_KEY=dev_key_123 trunk serve
|
|
```
|
|
|
|
### Production Build
|
|
```bash
|
|
# Build the WASM application
|
|
PORTAL_API_KEY=your_production_api_key trunk build --release
|
|
```
|
|
|
|
## Configuration
|
|
|
|
### Environment Variables
|
|
Create a `.env` file in the portal directory:
|
|
|
|
```bash
|
|
# Portal Client Configuration
|
|
PORTAL_API_KEY=dev_key_123 # Must match portal-server API_KEYS
|
|
```
|
|
|
|
### Stripe Configuration
|
|
Update the Stripe publishable key in `index.html`:
|
|
|
|
```javascript
|
|
const STRIPE_PUBLISHABLE_KEY = 'pk_test_your_actual_key_here';
|
|
```
|
|
|
|
## Server Integration
|
|
|
|
The portal connects to the portal-server running on `http://127.0.0.1:3001` with these endpoints:
|
|
|
|
- `POST /api/resident/create-payment-intent` - Create payment intent for resident registration (requires API key)
|
|
|
|
### API Authentication
|
|
All API calls include the `x-api-key` header for authentication. The API key is configured via the `PORTAL_API_KEY` environment variable.
|
|
|
|
## Troubleshooting
|
|
|
|
### Getting 401 Unauthorized Errors?
|
|
|
|
**Problem**: API calls to portal-server return 401 errors
|
|
|
|
**Solutions**:
|
|
1. **Check API Key Configuration**:
|
|
```bash
|
|
# Portal client .env
|
|
PORTAL_API_KEY=dev_key_123
|
|
|
|
# Portal server .env (must include the same key)
|
|
API_KEYS=dev_key_123,other_keys_here
|
|
```
|
|
|
|
2. **Verify Server is Running**:
|
|
```bash
|
|
curl -X GET http://127.0.0.1:3001/api/health \
|
|
-H "x-api-key: dev_key_123"
|
|
```
|
|
|
|
3. **Check Environment Variable Loading**:
|
|
```bash
|
|
# Make sure to source the .env file
|
|
source .env && trunk serve
|
|
|
|
# Or set inline
|
|
PORTAL_API_KEY=dev_key_123 trunk serve
|
|
```
|
|
|
|
### Portal Won't Start?
|
|
|
|
**Problem**: Trunk serve fails or portal doesn't load
|
|
|
|
**Solutions**:
|
|
1. **Install Dependencies**:
|
|
```bash
|
|
cargo install trunk
|
|
rustup target add wasm32-unknown-unknown
|
|
```
|
|
|
|
2. **Check WASM Target**:
|
|
```bash
|
|
rustup target list --installed | grep wasm32
|
|
```
|
|
|
|
3. **Build First**:
|
|
```bash
|
|
trunk build
|
|
trunk serve
|
|
```
|
|
|
|
### API Key Not Working?
|
|
|
|
**Problem**: Environment variable substitution not working
|
|
|
|
**Solutions**:
|
|
1. **Check Trunk Version**: Make sure you have a recent version of Trunk
|
|
2. **Manual Configuration**: If environment substitution fails, edit `index.html` directly:
|
|
```javascript
|
|
const PORTAL_API_KEY = 'your_actual_api_key_here';
|
|
```
|
|
|
|
## Development Workflow
|
|
|
|
### 1. Start Portal Server
|
|
```bash
|
|
cd ../portal-server
|
|
cargo run -- --from-env --verbose
|
|
```
|
|
|
|
### 2. Start Portal Client
|
|
```bash
|
|
cd ../portal
|
|
source .env && trunk serve
|
|
```
|
|
|
|
### 3. Test Integration
|
|
```bash
|
|
# Test server directly
|
|
curl -X GET http://127.0.0.1:3001/api/health \
|
|
-H "x-api-key: dev_key_123"
|
|
|
|
# Open portal in browser
|
|
open http://127.0.0.1:8080
|
|
```
|
|
|
|
## Purpose
|
|
|
|
This portal serves as the entry point for new users who want to become digital residents. Once they complete registration, they can be redirected to the full platform. |