Plaid Banking Integration
Relevant source files
The following files were used as context for generating this wiki page:
The Plaid Banking Integration is a core module of the BankChase application that enables users to securely connect their external bank accounts to the platform. It facilitates real-time account verification, balance checks, and transaction synchronization. The system utilizes Plaid's API to bridge the gap between traditional financial institutions and the BankChase digital environment, allowing for a consolidated view of financial data.
This integration is built using a React-based frontend and a Next.js API backend, leveraging JWT-based authentication to ensure secure data exchange. It supports multiple environments including Sandbox for testing and Production for live use. The module is deeply integrated with the Database Schema to persist linked account metadata and transaction history.
Sources: CHASE_SETUP_COMPLETE.md:5-17, EVERYTHING_WORKS.md:12-23
Architecture and Data Flow
The architecture follows a standard client-server pattern where the frontend initiates the connection via the Plaid Link modal, and the backend handles sensitive API communication and data persistence.
Integration Flow
The process begins with the generation of a link token and concludes with the exchange of a public token for a permanent access token stored in the database.
The sequence above illustrates the secure handshake required to establish a permanent link between the user's bank and the application.
Sources: EVERYTHING_WORKS.md:92-110, FINAL_SETUP_GUIDE.md:65-74
Core Components
Frontend Components
The integration relies on specialized React components to handle user interaction and data display.
| Component | Purpose | Key Functionality |
|---|---|---|
PlaidLinkButton | Initiation | Fetches link token and triggers the Plaid Link modal for bank selection. |
PlaidDashboard | Visualization | Displays linked account balances and synchronized transaction history. |
PlaidAccountsManager | Management | Allows users to view and manage multiple linked financial institutions. |
BankingDashboard | Main UI | The primary interface housing account sections and quick actions. |
Sources: CHASE_SETUP_COMPLETE.md:32-37, FINAL_SETUP_GUIDE.md:46-51
API Endpoints
All Plaid-related endpoints are protected by JWT Bearer token authentication to ensure that bank data is only accessible to the authorized user.
| Endpoint | Method | Description |
|---|---|---|
/api/plaid/create-link-token | POST | Generates a short-lived token required to initialize the Plaid Link flow. |
/api/plaid/exchange-token | POST | Exchanges a public_token for a permanent access_token. |
/api/plaid/accounts | GET | Fetches real-time account data and the last 30 days of transactions. |
/api/plaid/analytics | GET | Provides transaction analytics based on synchronized data. |
/api/plaid/webhook | POST | Handles incoming event notifications from Plaid (e.g., new transactions). |
Sources: CHASE_SETUP_COMPLETE.md:39-46, EVERYTHING_WORKS.md:58-75
Database Configuration
The system persists data using a Supabase PostgreSQL backend with an in-memory fallback for development environments. The schema is designed to separate sensitive access credentials from public metadata.
Data Schema Relationships
The diagram represents the relational structure where transactions and metadata are tied to specific linked accounts.
Sources: CHASE_SETUP_COMPLETE.md:21-26, FINAL_SETUP_GUIDE.md:104-124
Environment Configuration
The integration requires specific environment variables to authenticate with the Plaid API and the backend database.
# Plaid Credentials
PLAID_CLIENT_ID: "your-plaid-client-id"
PLAID_SECRET: "your-plaid-secret"
PLAID_ENV: "sandbox|development|production"
# Database Credentials
NEXT_PUBLIC_SUPABASE_URL: "your-supabase-url"
SUPABASE_SERVICE_ROLE_KEY: "your-supabase-key"
Sources: CHASE_SETUP_COMPLETE.md:73-79, EVERYTHING_WORKS.md:135-141
Security Implementation
The integration implements several layers of security to protect sensitive financial data:
- JWT Authentication: All API requests to
/api/plaid/*must include a valid JWT in the Authorization header. - Encrypted Storage: Access tokens are stored in the database with encryption (marked as ENCRYPTED in the schema).
- Token Isolation: The
public_tokenis temporary and only used during the initial exchange. - CORS Protection: Security headers are implemented to prevent unauthorized cross-origin requests.
Sources: CHASE_SETUP_COMPLETE.md:95-102, FINAL_SETUP_GUIDE.md:76-82
Testing in Sandbox
For development and testing, the application is pre-configured to work with the Plaid Sandbox environment.
- Test Institutions: Use "Sandbox Bank" during the Link flow.
- Credentials:
- Username:
user_good - Password:
pass_good - MFA Code:
123456
- Username:
- Custom Scenarios: Specific usernames like
user_customcan be used to test various bank-specific behaviors.
Sources: CHASE_SETUP_COMPLETE.md:85-90, FINAL_SETUP_GUIDE.md:131-138
The Plaid Banking Integration provides a robust foundation for the BankChase application's financial features. By combining secure token exchange, real-time data synchronization, and a scalable database schema, the system allows users to manage external financial accounts with high reliability and security. The module is fully functional and ready for production deployment upon the configuration of live credentials.
Sources: EVERYTHING_WORKS.md:162-171, SYSTEM_STATUS_REPORT.md:255-263