.. | ||
src | ||
static | ||
.env.example | ||
AUTHENTICATION_FIX.md | ||
Cargo.lock | ||
Cargo.toml | ||
index.html | ||
QUICK_START.md | ||
README.md | ||
REFACTORING_IMPLEMENTATION_PLAN.md | ||
setup.sh | ||
test-env.sh | ||
TROUBLESHOOTING.md | ||
Trunk.toml |
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:
# 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:
# 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
# Install trunk if you haven't already
cargo install trunk
# Load environment variables and serve
source .env && trunk serve
Building and Running
Development Mode
# 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
# 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:
# 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
:
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:
-
Check API Key Configuration:
# 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
-
Verify Server is Running:
curl -X GET http://127.0.0.1:3001/api/health \ -H "x-api-key: dev_key_123"
-
Check Environment Variable Loading:
# 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:
-
Install Dependencies:
cargo install trunk rustup target add wasm32-unknown-unknown
-
Check WASM Target:
rustup target list --installed | grep wasm32
-
Build First:
trunk build trunk serve
API Key Not Working?
Problem: Environment variable substitution not working
Solutions:
- Check Trunk Version: Make sure you have a recent version of Trunk
- Manual Configuration: If environment substitution fails, edit
index.html
directly:const PORTAL_API_KEY = 'your_actual_api_key_here';
Development Workflow
1. Start Portal Server
cd ../portal-server
cargo run -- --from-env --verbose
2. Start Portal Client
cd ../portal
source .env && trunk serve
3. Test Integration
# 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.