|
| 1 | +Based on the analysis of the existing code and the provided requirements, I have developed a comprehensive plan to implement the missing **Particle Network Integration** and verify the **Payment & Dashboard** flows. |
| 2 | + |
| 3 | +The existing codebase already has a robust implementation for: |
| 4 | +- **Dashboard**: Backend services and frontend charts are implemented and connected. |
| 5 | +- **Crypto Payments**: Alchemy webhook handlers and invoice matching logic are present. |
| 6 | +- **Database**: Core schemas for Users, Invoices, and Ledger Entries are ready. |
| 7 | + |
| 8 | +The main missing piece is the **Particle Network Authentication** flow described in your diagram. |
| 9 | + |
| 10 | +### **Phase 1: Database Schema Update** |
| 11 | +- **Action**: Update `prisma/schema.prisma` to add `particleUuid` field to the `User` model. |
| 12 | +- **Reason**: To link Particle social logins (Twitter/Google/etc.) to the internal User record. |
| 13 | + |
| 14 | +### **Phase 2: Particle Network Integration (Frontend)** |
| 15 | +- **Action**: Install `@particle-network/auth-core-modal` and `@particle-network/chains`. |
| 16 | +- **Action**: Create `src/components/auth/particle-provider.tsx` to initialize the SDK. |
| 17 | +- **Action**: Create `src/components/auth/login-button.tsx` to handle the "Connect with Social" flow. |
| 18 | +- **Action**: Update the login page to include this new authentication method. |
| 19 | + |
| 20 | +### **Phase 3: Backend Authentication Logic** |
| 21 | +- **Action**: Add a new tRPC procedure `auth.loginWithParticle`. |
| 22 | +- **Logic**: |
| 23 | + 1. Receive the Particle User Info (UUID, Email, Wallets) from the frontend. |
| 24 | + 2. Find or Create a user in the database based on `email` or `particleUuid`. |
| 25 | + 3. Automatically create/update `WalletAddress` records for the user (Arbitrum/Base/Polygon) as per the diagram. |
| 26 | + 4. Return a session token (JWT) to log the user in. |
| 27 | + |
| 28 | +### **Phase 4: Configuration & Documentation** |
| 29 | +- **Action**: Update `.env.example` with required Particle API keys (`NEXT_PUBLIC_PARTICLE_PROJECT_ID`, etc.). |
| 30 | +- **Action**: Add a TODO checklist for you to fill in the actual keys from the Particle Dashboard. |
| 31 | + |
| 32 | +### **Phase 5: Verification** |
| 33 | +- **Action**: Verify the "Payment -> Webhook -> Ledger" flow by reviewing the `alchemy-webhook.handler.ts` (already analyzed, looks good) and ensuring the `WalletAddress` creation in Phase 3 aligns with what the webhook expects. |
| 34 | + |
| 35 | +I will start by updating the schema and installing the necessary dependencies. |
0 commit comments