mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-08-12 12:13:21 +00:00
Adds a multi-step onboarding wizard for initial setup and integrates status checks to determine when it should be displayed. Includes API client updates and documentation. Co-authored-by: db2002dominic <db2002dominic@gmail.com>
5.1 KiB
5.1 KiB
Onboarding Wizard
The Routstr onboarding wizard is an interactive setup guide that helps new users configure their AI routing system quickly and easily.
Overview
The onboarding wizard automatically appears when:
- No admin password has been set, OR
- No upstream providers are configured
This ensures that essential setup steps are completed before the system is used.
Features
Multi-Step Setup Process
The wizard guides users through five key steps:
1. Welcome Screen
- Introduces Routstr and its capabilities
- Explains what will be configured during onboarding
- Shows key features:
- Admin access setup
- AI provider connections
- Node configuration
2. Set Admin Password
- Secure the admin dashboard with a password
- Password must be at least 8 characters
- Confirms password to prevent typos
- Automatically logs in the user after setup
3. Add AI Provider
- Connect the first AI provider to start routing requests
- Supports multiple provider types:
- OpenRouter (default)
- OpenAI
- Anthropic
- Azure
- Groq
- Perplexity
- xAI
- Fireworks
- And more...
- Provides direct links to get API keys
- Validates API key presence before proceeding
4. Optional Settings
- Configure node name and description
- Can be skipped if desired
- Settings can be changed later in the Settings page
5. Completion
- Confirms successful setup
- Provides next steps:
- Add more providers
- Configure models
- Monitor usage
- Redirects to dashboard
User Experience
Visual Design
- Progress bar shows completion percentage
- Step counter (e.g., "Step 2 of 5")
- Consistent iconography for each step
- Clear navigation with Back/Next buttons
Skip Option
- "Skip for now" button on the welcome screen
- Allows advanced users to configure manually
- Marks onboarding as completed
Persistence
- Uses localStorage to track completion
- Won't show again once completed
- Can be reset by clearing browser storage
Technical Implementation
Files Created/Modified
-
/ui/components/onboarding-wizard.tsx- Main onboarding component
- Multi-step wizard logic
- Form validation and submission
- API integration
-
/ui/lib/onboarding.ts- Onboarding status checking
- Persistence management
- Determines if onboarding is needed
-
/ui/app/page.tsx- Integration point on dashboard
- Status check on load
- Shows wizard when needed
-
/ui/lib/api/client.ts- Added
setAuthTokenmethod - Handles authentication after setup
- Added
API Endpoints Used
POST /admin/api/setup- Initial password setup (no auth required)POST /admin/api/login- Login after setupGET /admin/api/provider-types- List available providersPOST /admin/api/upstream-providers- Create providerPATCH /admin/api/settings- Update node settings
State Management
The wizard uses React Query for:
- Fetching provider types
- Creating providers
- Updating settings
- Managing loading states
Error Handling
- Validates password length and match
- Requires API key for provider setup
- Shows user-friendly error messages
- Handles API failures gracefully
Security Considerations
-
Password Requirements
- Minimum 8 characters
- Must match confirmation
- Stored securely in backend
-
API Key Storage
- Keys are sent securely to backend
- Never stored in localStorage
- Transmitted over HTTPS in production
-
Authentication Flow
- Setup endpoint doesn't require auth
- Subsequent steps use JWT token
- Token stored with expiration
Customization
Adding New Steps
To add a step to the wizard:
- Add step definition to
stepsarray:
{
id: 'mystep',
title: 'My Step Title',
description: 'Step description',
icon: <MyIcon className="h-12 w-12 text-color-500" />,
}
- Add case to
renderStepContent()switch - Add validation logic to
canProceed() - Add submission logic to
handleNext()
Modifying Conditions
To change when onboarding appears, edit checkOnboardingStatus() in /ui/lib/onboarding.ts.
Resetting Onboarding
To force onboarding to appear again:
localStorage.removeItem('onboardingCompleted');
Or use the helper:
import { resetOnboarding } from '@/lib/onboarding';
resetOnboarding();
Testing
Manual Testing Checklist
- Onboarding appears on first visit
- Password validation works correctly
- Provider creation succeeds with valid API key
- Optional settings can be skipped
- Completion redirects to dashboard
- Skip button works on welcome screen
- Back button navigates correctly
- Progress bar updates accurately
- Error messages display properly
- Authentication persists after setup
Testing Fresh Installation
- Clear browser localStorage
- Ensure no admin password is set in backend
- Ensure no providers exist
- Visit dashboard
- Verify onboarding appears automatically
Future Enhancements
Potential improvements:
- Add model configuration step
- Include wallet setup guidance
- Provide API testing step
- Add video tutorials
- Support multiple languages
- Enable custom provider configurations