How icoretech/airbroke works
Main Components
• Frontend/UI: Built with React/Next.js residing in the “app” directory. Includes pages for bookmarks, projects, sign-in, error occurrence display, etc.
• API Endpoints: Located under “app/api” with further subdivisions:
– Auth endpoints (for NextAuth-based user authentication)
– Data Collection API endpoints (receiving error reports and performing in-band error processing)
– Health-check endpoints and v3 endpoints for notices.
• Authentication Layer: Supported via NextAuth with multiple providers (GitHub, Google, etc.) and configured via environment variables in .env.
• Database: PostgreSQL accessed via Prisma (see the “prisma” folder with migrations, schema.prisma, and seed.ts).
• Utility & Business Logic: Code in “lib” (for actions, error processing, integrations, queries, etc.) that handles key logic such as generating updated URLs or parsing notices.
• Testing: __tests__ directory contains tests for API endpoints, pages, and libraries.
• Deployment & DevOps: Supporting files like Dockerfile, docker-compose.yml, GitHub workflows, and Makefile indicate multiple deployment scenarios including Docker image builds and Kubernetes deployments.
Relationships and Data Flow
• Clients (browsers) interact with the front-end UI hosted as Next.js pages.
• The frontend communicates with underlying API routes (HTTP endpoints) to perform key tasks like error ingestion, authentication, fetching error details, managing projects, and more.
• The Data Collection API endpoint receives error reports (using an Airbrake-compatible HTTP collector endpoint) and processes them synchronously.
• The authentication layer, based on NextAuth, sits between the client and the API, handling user sessions and OAuth provider integrations.
• Both the frontend and the API interact with the PostgreSQL database using Prisma; one connection (via DATABASE_URL) is for in-app operations while DIRECT_URL is used for migrations in deployment contexts.
• The DevOps setup (Docker, docker-compose, GitHub Actions, Render, Vercel, Helm chart etc.) is used to build, test, and deploy the entire system.
Architectural Patterns and Design Choices
• All-in-One Next.js Application: The project uses Next.js’s hybrid model where the frontend and backend APIs coexist in a single codebase.
• Server-Side Rendering (SSR) and Static Generation: The use of Next.js implies usage of optimized page rendering for performance.
• Modular Component-based UI: The “components” directory is rich with reusable React components (e.g., for occurrence charts, bookmarks, confirmation dialogs).
• API Route Segmentation: The API endpoints are structured using path-based routing (e.g., /api/auth, /api/completion), helping to separate concerns (authentication, error collection, notice management).
• Database Schema & Migrations: The “prisma” folder shows that the project uses migrations for schema evolution, encapsulating database design.
• Containerization: Docker configurations and related scripts show that containerization is employed, making the system deployment-ready across multiple environments.
• Connections: Use annotations or call-outs near API endpoints to mention that they are Airbrake-compatible and process error reports synchronously.
• Deployment Options: Include optional branches for deployment mechanisms (Docker, Vercel, Render, Helm) to demonstrate the flexible multi-deployment approach.