Frontend Separation Guide¶
The web onboarding frontend has been extracted from the backend API into a separate package for independent deployment.
📦 Frontend Package Location¶
File: sage-onboarding-frontend.tar.gz (13KB, in this repository root)
To extract:
📁 Package Contents¶
sage-onboarding-frontend/
├── README.md # Quick start guide
├── API_INTEGRATION.md # Complete API integration documentation
├── DEPLOYMENT.md # Deployment guides for various platforms
├── .env.example # Environment variable template
├── package.json # Node.js dependencies (optional)
├── server.js # Optional Node.js server
├── templates/ # HTML pages
│ ├── onboarding_welcome.html # Step 1: Phone entry
│ ├── onboarding_verify.html # Step 2: OTP verification + profile
│ ├── onboarding_trial.html # Step 3: Trial payment
│ └── onboarding_success.html # Step 4: Success confirmation
└── static/
└── css/
└── onboarding.css # Mobile-first responsive styles
🚀 Quick Deploy Options¶
Option 1: Static Hosting (Netlify, Vercel, S3)¶
Best for: Simple deployments, serverless
Option 2: Node.js Server (Cloud Run, ECS, Heroku)¶
Best for: Full control, custom logic
Option 3: Any Web Server (Nginx, Apache)¶
Best for: Traditional hosting
Just serve the templates/ and static/ directories.
🔗 Backend API Integration¶
The frontend will call these backend endpoints:
Authentication Flow:¶
POST /auth/verify/start- Send OTP codePOST /auth/verify/confirm- Verify OTP + submit profileGET /auth/session- Check authentication status
Payment Flow:¶
POST /payment/checkout/trial- Create $5 trial checkoutPOST /payment/checkout/topup- Create credit top-up checkoutGET /payment/status/{user_id}- Get payment status
Usage & Credits:¶
GET /usage/balance/{user_id}- Get credit balanceGET /usage/history/{user_id}- Get transaction historyGET /usage/pricing- Get pricing information
Full API documentation: See API_INTEGRATION.md in the package
⚙️ Configuration Required¶
Frontend Environment Variables:¶
Backend CORS Configuration:¶
In app/main.py, add your frontend domain to allowed origins:
allowed_origins = [
"https://your-frontend-domain.com",
"http://localhost:3000", # For local development
]
📋 For the Frontend Engineer¶
Step-by-Step Setup:¶
-
Extract the package:
-
Read the documentation:
README.md- Overview and quick startAPI_INTEGRATION.md- Complete API reference with examples-
DEPLOYMENT.md- Platform-specific deployment guides -
Configure environment:
-
Test locally:
-
Update JavaScript API URLs: All HTML files are configured to use
window.ENV?.BACKEND_API_URLwhich falls back tohttp://localhost:8000.
To use environment variables, you can:
- Set window.ENV = { BACKEND_API_URL: 'https://api.example.com' } in a config script
- Or use the Node.js server which can inject environment variables
- Or find/replace http://localhost:8000 with your production API URL
- Deploy to your platform:
-
See
DEPLOYMENT.mdfor Netlify, Vercel, AWS S3, Docker, etc. -
Configure backend CORS:
-
Contact backend team to add your domain to allowed origins
-
Test the complete flow:
- Welcome → Verify → Trial → Success
- Verify phone verification works
- Verify Stripe checkout works
- Check that cookies are being set/sent properly
🔒 Security Checklist¶
- Frontend deployed via HTTPS
- Backend CORS configured for frontend domain
- Environment variables configured (not hardcoded)
- API calls include
credentials: 'include'for cookies - Test phone verification in Twilio test mode
- Test Stripe checkout in test mode
- Verify secure cookies are working
📞 Support¶
Frontend Issues:¶
- Deployment problems → See
DEPLOYMENT.md - API integration questions → See
API_INTEGRATION.md - Environment configuration → See
.env.example
Backend Issues:¶
- API endpoints not working → Check backend logs
- CORS errors → Verify frontend domain in backend's allowed_origins
- Authentication errors → Verify cookies are being sent
🎯 What Changed in Backend¶
The following were removed from the backend repository:
- web/templates/ directory (all HTML files)
- web/static/ directory (CSS files)
- app/api/web_routes.py (web page serving routes)
The backend is now a pure API service with no frontend code.
📈 Next Steps¶
- For Frontend Engineer:
- Extract package
- Read API_INTEGRATION.md thoroughly
- Set up local development
- Deploy to staging environment
- Test complete flow
-
Deploy to production
-
For Backend Team:
- Ensure CORS is configured
- Verify all API endpoints are working
- Set up Twilio and Stripe in production
-
Monitor API usage and errors
-
For Both Teams:
- Coordinate on API contract changes
- Share error logs for debugging
- Document any API changes
- Test end-to-end flow together
📚 Additional Resources¶
- Twilio Test Numbers: https://www.twilio.com/docs/iam/test-credentials
- Stripe Test Cards: https://stripe.com/docs/testing
- Backend API Source: This repository
- Frontend Package:
sage-onboarding-frontend.tar.gz