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
9.0 KiB
CollabTable - Updates Summary
Latest Changes (October 2025)
Field Editing Feature
Added ability to edit field types and options after creation
Android Changes:
-
New
EditFieldDialogcomposable inListDetailScreen.kt- Allows changing field type (STRING, PRICE, DROPDOWN, URL, DATE, TIME, DATETIME)
- Modify dropdown options or currency symbols
- Similar UI to AddFieldDialog for consistency
-
FieldHeader enhancements
- Added Edit icon button next to field name
- Click to open EditFieldDialog
- Long-press still deletes field
-
ViewModel update
- New
updateField()method inListDetailViewModel - Updates field type and options in database
- Properly maintains field state
- New
Use case: Change a STRING field to a DROPDOWN, or update dropdown options without recreating the field.
Password Authentication Feature
Server-side password protection with Android client support
Server Changes:
-
Environment Configuration (
.env.example)- Added
SERVER_PASSWORDenvironment variable - Set your secure password in
.envfile
- Added
-
Authentication Middleware (
src/middleware/auth.ts)- Validates password on all
/api/*routes - Uses Bearer token format:
Authorization: Bearer <password> /healthendpoint remains unauthenticated- Returns 401 for missing or invalid passwords
- Validates password on all
-
Server Integration (
src/index.ts)- Auth middleware applied before route handlers
- All API calls now require valid password
- Health check accessible without auth
Android Changes:
-
PreferencesManager updates
getServerPassword()andsetServerPassword()methods- Secure storage in SharedPreferences
- Password persists across app sessions
-
ServerSetupScreen enhancements
- New password input field with show/hide toggle
- Password required for setup completion
- Validates password during initial setup
- Tests authentication before saving
-
ServerSetupViewModel
- Updated
validateAndSaveServerUrl()to accept password - Two-step validation: health check + authenticated request
- Stores password only after successful authentication
- Clear error messages for auth failures
- Updated
-
ApiClient authentication
- New auth interceptor adds
Authorizationheader - Automatically includes password in all API requests
- Retrieves password from PreferencesManager
- No code changes needed in individual API calls
- New auth interceptor adds
Setup Instructions:
Server:
# Set password in .env file
echo "SERVER_PASSWORD=your_secure_password" >> .env
# Restart server
docker-compose restart
Android:
- Open app (first time or after reset)
- Enter server URL
- Enter server password
- Tap "Validate and Continue"
- Password is validated and stored
Security Notes:
- Password stored in Android SharedPreferences (encrypted on modern devices)
- Password sent via HTTPS in production (use SSL certificates)
- Consider using more robust auth (OAuth, JWT) for production use
- Current implementation is simple password-based authentication
Previous Changes
Android App Enhancements
1. Settings Screen Added
-
New Files:
PreferencesManager.kt- Manages persistent storage of settingsSettingsScreen.kt- UI for configuring server URLSettingsViewModel.kt- Business logic for settings
-
Features:
- Settings icon in the main Lists screen toolbar
- Configurable server URL with validation
- Helpful tips for emulator vs physical device URLs
- Persistent storage across app restarts
- Success notification when URL is updated
2. API Client Updates
ApiClient.ktnow initializes with saved preferences- Server URL can be changed at runtime
- Automatically loads saved URL on app start
3. Navigation Updates
- Added settings route to navigation graph
- Settings accessible from Lists screen
Server Migration to SQLite
1. Database Change
- Replaced: MongoDB → SQLite with Sequelize ORM
- Reason: Simpler deployment, built-in persistence, no separate database container needed
2. Updated Dependencies
- Removed:
mongoose - Added:
sequelize,sqlite3
3. New Database Configuration
database.ts- Sequelize connection setup- Database path configurable via
DB_PATHenvironment variable - Default location:
/data/collabtable.db
4. Model Updates
All models converted from Mongoose schemas to Sequelize models:
List.tsField.tsItem.tsItemValue.ts
5. Routes Updates
All route handlers updated to use Sequelize methods:
findAll()instead offind()upsert()instead offindOneAndUpdate()- Sequelize operators (
Op.gt) instead of MongoDB operators ($gt)
Docker Configuration
1. Simplified Setup
- Removed: MongoDB container
- Changed: Single server container with SQLite
- Result: Faster startup, simpler architecture
2. Persistent Storage
- Docker volume:
sqlite_data - Mounted at:
/datain container - Persists across:
- Container restarts
- Container recreation
docker-compose down/upcycles
3. Environment Variables
PORT- Server port (default: 3000)DB_PATH- SQLite database path (default: /data/collabtable.db)NODE_ENV- Environment mode
How to Use
Start the Server
cd CollabTableServer
docker-compose up -d
Configure Android App
- Open app in Android Studio
- Build and run on device/emulator
- Tap Settings icon (⚙️) in top bar
- Enter server URL:
- Emulator:
http://10.0.2.2:3000/api/ - Physical Device:
http://YOUR_IP:3000/api/
- Emulator:
- Tap "Save"
Backup Database
# Backup
docker cp collabtable-server:/data/collabtable.db ./backup.db
# Restore
docker cp ./backup.db collabtable-server:/data/collabtable.db
docker-compose restart
Benefits
Android App
✅ No hardcoded server URLs ✅ Easy to switch between environments ✅ User-friendly configuration ✅ Clear instructions for different device types
Server
✅ Simpler deployment (one container vs two) ✅ No database configuration needed ✅ Built-in data persistence ✅ Easy backups (single file) ✅ Lower resource usage ✅ Faster startup time
Testing
Test Server Persistence
# Start server
docker-compose up -d
# Use the app to create data
# ...
# Restart server
docker-compose restart
# Data should still be there!
# Even after complete teardown
docker-compose down
docker-compose up -d
# Data persists because of the volume!
Test Settings
- Open app
- Go to Settings
- Change server URL
- Close app
- Reopen app
- Go to Settings - URL should be saved!
Architecture Diagram
┌─────────────────────┐
│ Android App │
│ (Material 3 UI) │
│ │
│ ┌───────────────┐ │
│ │ Settings │ │
│ │ Screen │ │
│ └───────────────┘ │
│ ↓ │
│ ┌───────────────┐ │
│ │ Preferences │ │
│ │ Manager │ │
│ └───────────────┘ │
│ ↓ │
│ ┌───────────────┐ │
│ │ API Client │ │
│ └───────────────┘ │
└──────────┬──────────┘
│ HTTP/REST
↓
┌─────────────────────┐
│ Docker Container │
│ │
│ ┌───────────────┐ │
│ │ Express.js │ │
│ │ Server │ │
│ └───────┬───────┘ │
│ ↓ │
│ ┌───────────────┐ │
│ │ Sequelize │ │
│ │ ORM │ │
│ └───────┬───────┘ │
│ ↓ │
│ ┌───────────────┐ │
│ │ SQLite │ │
│ │ Database │ │
│ └───────────────┘ │
│ ↓ │
│ /data/collabtable.db
│ ↓ │
└──────────┬──────────┘
│
Docker Volume
(sqlite_data)
Notes
- TypeScript compilation errors shown are expected until dependencies are installed
- Run
npm installin the server directory before local development - The Android app works offline-first and syncs when connected
- Server validates and sanitizes all incoming data
- Timestamps are used for conflict resolution (latest wins)