feat: Add sync routes for data synchronization between client and server feat: Create web routes for serving UI and data visualization chore: Configure TypeScript for the server project docs: Update README with project overview, features, and setup instructions docs: Add server setup implementation details for first-run configuration docs: Summarize updates and changes in the project, including new features and enhancements
4.4 KiB
4.4 KiB
Server Setup Feature - Implementation Summary
Overview
Added a mandatory server setup screen on first app startup with endpoint validation to ensure users configure a valid server URL before using the app.
Features Added
1. First-Run Server Setup Screen
- File:
ServerSetupScreen.kt - Mandatory setup screen shown on first app launch
- User-friendly interface with clear instructions
- Real-time validation feedback with visual indicators
- Cannot be skipped - must validate successfully to proceed
- Tips card with connection examples for emulator and physical devices
2. Server Endpoint Validation
- File:
ServerSetupViewModel.kt - Validates URL format (must start with http:// or https://)
- Tests server connectivity by calling the
/healthendpoint - Shows specific error messages:
- Connection failures
- Timeout errors
- Invalid URL format
- Server error codes
- Loading states with progress indicators
- Success confirmation before proceeding
3. First-Run Detection
- Updated:
PreferencesManager.kt - Added
isFirstRun()method to check if app has been configured - Added
setIsFirstRun(Boolean)method to mark setup as complete - Persists across app restarts using SharedPreferences
4. Updated Navigation Flow
- Updated:
AppNavigation.kt - Dynamically determines start destination based on first-run status
- Shows
server_setupscreen on first run - Shows
listsscreen on subsequent runs - Prevents navigation back to setup after completion
User Experience Flow
First App Launch:
- User opens app for the first time
- Server Setup screen is displayed automatically
- User enters server URL
- App validates the endpoint:
- Shows loading indicator during validation
- Displays success checkmark if valid
- Shows error message if invalid
- On successful validation:
- Server URL is saved
- First-run flag is set to false
- User is navigated to Lists screen
- User can now use the app normally
Subsequent Launches:
- User opens app
- App checks first-run status
- Directly shows Lists screen (normal flow)
- User can still change server URL via Settings
Validation Process
The validation performs these checks:
- URL Format: Ensures URL starts with http:// or https://
- Normalization: Adds trailing slash if missing
- Health Check: Calls
/healthendpoint (converted from/api/path) - Timeout: 10-second timeout for connection attempts
- Error Handling: User-friendly error messages for common issues
Error Messages
- "URL must start with http:// or https://"
- "Cannot connect to server. Check URL and network."
- "Connection timeout. Server might be offline."
- "Server returned error: [code]"
- "Invalid URL format"
- "Error: [specific error message]"
Settings Integration
Users can still:
- Change server URL later via Settings screen
- Test new URLs at any time
- View connection tips in Settings
Technical Details
Dependencies Used:
- OkHttp for HTTP requests
- Kotlin Coroutines for async operations
- StateFlow for reactive state management
- SharedPreferences for persistence
Network Configuration:
- Connection timeout: 10 seconds
- Read timeout: 10 seconds
- Validates against
/healthendpoint - Supports both HTTP and HTTPS
Testing Recommendations
-
First Run Test:
- Clear app data
- Launch app
- Verify server setup screen appears
-
Validation Test:
- Test with valid URL (should succeed)
- Test with invalid URL (should show error)
- Test with unreachable server (should show connection error)
- Test with malformed URL (should show format error)
-
Subsequent Launch Test:
- After successful setup, close and reopen app
- Verify Lists screen appears directly
-
Settings Test:
- Navigate to Settings
- Change server URL
- Verify changes persist
Files Modified/Created
New Files:
app/src/main/java/com/collabtable/app/ui/screens/ServerSetupScreen.ktapp/src/main/java/com/collabtable/app/ui/screens/ServerSetupViewModel.kt
Modified Files:
app/src/main/java/com/collabtable/app/data/preferences/PreferencesManager.ktapp/src/main/java/com/collabtable/app/ui/navigation/AppNavigation.kt
Build Status
✅ Build successful with all tests passing ✅ No compilation errors ✅ All dependencies resolved correctly