mirror of
https://github.com/FranP-code/inbox-negotiator.git
synced 2025-10-13 00:42:26 +00:00
5.2 KiB
5.2 KiB
Appwrite Migration Progress
Completed Migrations
1. Dependencies
- ✅ Installed Appwrite SDK v16.0.2
- ✅ Removed @supabase/supabase-js dependency
- ✅ Updated package.json
2. Core Configuration
- ✅ Created
src/lib/appwrite.ts- Main client configuration - ✅ Created
src/lib/appwrite-admin.ts- Server-side admin operations - ✅ Updated environment variables in
.env.example
3. Authentication Components
- ✅
src/components/AuthForm.tsx- Migrated to Appwrite Account API - ✅
src/components/AuthGuard.tsx- Updated session management - ✅
src/components/Navbar.tsx- Updated user state handling
4. Database Operations
- ✅
src/components/Dashboard.tsx- Partially migrated database queries - ✅
src/pages/api/postmark.ts- Migrated webhook API to use Appwrite - ✅
src/components/DebtCard.tsx- Migrated debt operations and function calls - 🔄
src/components/Configuration.tsx- Partially migrated user data fetching
5. Function Calls
- ✅ Updated function invocation from Supabase to Appwrite Functions API
- ✅ Changed authentication headers from Bearer tokens to X-Appwrite-Project/X-Appwrite-Key
Required Appwrite Setup
Environment Variables
PUBLIC_APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
PUBLIC_APPWRITE_PROJECT_ID=your_project_id
PUBLIC_APPWRITE_DATABASE_ID=your_database_id
APPWRITE_API_KEY=your_api_key
Auto-Deploy Functions Setup
1. Install Appwrite CLI
npm install -g appwrite-cli
2. Initialize Appwrite Project
pnpm run setup:appwrite
# or manually: appwrite init project --project-id your_project_id
3. Deploy Functions Automatically
# Deploy all functions to Appwrite
pnpm run deploy:functions
# Or run the script directly
./scripts/deploy-appwrite-functions.sh
4. GitHub Actions Auto-Deploy
The repository includes a GitHub Actions workflow (.github/workflows/deploy-appwrite-functions.yml) that automatically deploys functions when:
- Changes are pushed to the
mainbranch - Files in
appwrite/functions/orsupabase/functions/are modified - Manually triggered via workflow dispatch
Required GitHub Secrets:
APPWRITE_PROJECT_ID- Your Appwrite project IDAPPWRITE_API_KEY- Your Appwrite API key with Functions write permissionsAPPWRITE_ENDPOINT- Your Appwrite endpoint (default: https://cloud.appwrite.io/v1)GOOGLE_AI_API_KEY- For AI-powered functionsPOSTMARK_SERVER_TOKEN- For email functions
Database Collections to Create
- debts - Main debt records
- audit_logs - Action logging
- user_profiles - User settings and preferences
- additional_emails - Secondary email addresses
- email_processing_usage - Monthly usage tracking
- debt_variables - Custom debt variables
- conversation_messages - Email conversation history
- users - User personal data
Functions to Migrate
- negotiate - AI debt negotiation logic
- approve-debt - Debt approval workflow
- send-email - Email sending functionality
- analyze-response - Email response analysis
- test-extraction - Debt information extraction testing
Remaining Tasks
Components Not Yet Migrated
src/components/ConversationTimeline.tsxsrc/components/OnboardingDialog.tsxsrc/components/ManualResponseDialog.tsxsrc/components/DebtTimeline.tsxsrc/components/RealtimeTestButton.tsxsrc/components/ExtractionTester.tsx
Migration Notes
Authentication
- Replaced
supabase.auth.signUp()withaccount.create()+account.createEmailPasswordSession() - Replaced
supabase.auth.signInWithPassword()withaccount.createEmailPasswordSession() - Replaced
supabase.auth.getUser()withaccount.get() - Replaced
supabase.auth.signOut()withaccount.deleteSession('current')
Database Operations
- Replaced
supabase.from().select()withdatabases.listDocuments() - Replaced
supabase.from().insert()withdatabases.createDocument() - Replaced
supabase.from().update()withdatabases.updateDocument() - Note: Appwrite queries use different syntax than Supabase filters
Function Calls
- Replaced
supabase.functions.invoke()withfunctions.createExecution() - Changed authentication from Authorization header to X-Appwrite-Project/X-Appwrite-Key headers
Real-time Updates
- Supabase real-time subscriptions need to be replaced with Appwrite real-time
- Currently using polling as a temporary fallback
Testing Required
-
Authentication Flow
- User registration
- User login/logout
- Session persistence
-
Database Operations
- Debt creation and updates
- User profile management
- Audit logging
-
Function Execution
- Email sending
- AI negotiation
- Response analysis
-
API Endpoints
- Postmark webhook processing
- Email parsing and storage
Production Deployment Checklist
- Set up Appwrite project and database
- Create all required collections with proper schemas
- Deploy Appwrite Functions (migrated from Supabase Edge Functions)
- Configure environment variables
- Set up proper permissions and security rules
- Test all functionality end-to-end
- Migrate data from Supabase to Appwrite
- Update DNS/domain configuration if needed