Monitoring & Audit Logging
Relevant source files
The following files were used as context for generating this wiki page:
The Monitoring and Audit Logging system in BankChase provides a robust, multi-layered framework for tracking system health and ensuring accountability for sensitive operations. It is designed to capture immutable logs of administrative actions, track authentication attempts, and provide real-time health metrics for critical infrastructure like MongoDB and PostgreSQL. This system is a core component of the project's Security Architecture, ensuring that all forensic trails are preserved and system throughput remains within operational limits.
Sources: README_START_HERE.md, DELIVERY_SUMMARY.md
System Health Monitoring
BankChase implements automated health checks to ensure the availability and performance of its hybrid database architecture. The system monitors connection status and latency for both PostgreSQL (Supabase) and MongoDB Atlas.
Health Check Infrastructure
The centralized health endpoint provides a status report on the backend services. It verifies the reachability of the primary databases and returns performance metrics such as response times.
The flow above illustrates how the system aggregates database statuses before responding to a monitoring request. Sources: app/api/admin/health/route.ts, DELIVERY_SUMMARY.md
Performance Metrics
The system is optimized for high throughput and tracks the following performance targets:
| Component | Metric | Target Value |
|---|---|---|
| Login Response | Latency | 50ms |
| Transaction Record | Latency | 5ms |
| Transaction Throughput | Multi-channel | 50K/sec |
| Admin Audits | Logging Capacity | 5K/sec |
Sources: DELIVERY_SUMMARY.md, README_START_HERE.md
Administrative Audit Logging
Audit logging in BankChase is primarily focused on tracking administrative actions to maintain a forensic trail. These logs are stored in an immutable PostgreSQL table and are accessible to users with the 'Admin' or 'Auditor' roles.
Audit Log Data Model
Each audit log entry captures a comprehensive context of the action performed. This includes the identity of the actor, the nature of the change, and technical metadata about the request.
| Field | Description |
|---|---|
id | Unique identifier for the log entry. |
admin_id | Foreign key referencing the user who performed the action. |
action_type | The specific operation (e.g., UPDATE_USER_ROLE, DELETE_USER). |
target_resource | The ID or description of the resource modified. |
ip_address | The IP of the client that initiated the request. |
user_agent | The browser/device information of the client. |
details | JSON object containing the specific payload or changes made. |
Sources: RBAC_SYSTEM_ARCHITECTURE.md, DELIVERY_SUMMARY.md
Logic Flow for Audit Entry Creation
When an administrative action is triggered (e.g., updating a user role via app/api/admin/users/route.ts), the system executes the action and the log entry within a database transaction to ensure atomicity.
Security and Compliance Logging
Beyond administrative actions, the system logs security-sensitive events such as authentication attempts and data access drifts.
Authentication and Login History
The login_history table records every authentication attempt, providing visibility into potential brute-force attacks or unauthorized access patterns.
- Success Tracking: Records successful 2FA verifications.
- Failure Tracking: Captures failed attempts with reason codes (e.g., invalid password, expired 2FA).
- Device Identification: Records IP addresses and User Agents for every session creation.
Sources: RBAC_SYSTEM_ARCHITECTURE.md, DELIVERY_SUMMARY.md
Immutability and Roles
The logging system utilizes PostgreSQL Row Level Security (RLS) to protect log data.
- Admins: Can insert and read all audit logs to manage system state.
- Auditors: Have strictly read-only access to audit logs and login history for compliance reviews.
- Immutability: The database schema is configured to prevent the modification or deletion of existing log entries once written.
Sources: RBAC_SYSTEM_ARCHITECTURE.md, RBAC_INDEX.md
Summary
The Monitoring & Audit Logging system is the backbone of accountability within BankChase. By separating operational monitoring (Health Checks) from forensic logging (Audit Trails), the project achieves high reliability and security. Every administrative change is captured with an immutable record containing IP and device metadata, while real-time metrics ensure the hybrid PostgreSQL/MongoDB stack maintains sub-100ms response times for critical banking operations.