# aclovestech/contributrack architecture

> Architecture diagram of the GitHub repository aclovestech/contributrack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aclovestech/contributrack
- Repository: https://github.com/aclovestech/contributrack

## Overview

##### Main Components
- Client/Browser Interface – Representing the end-user experience. Highlight the Next.js “app” folder which contains the main pages including authentication, dashboard areas (donations, donors, reports) and the global layout.
- Frontend UI Components – Include the various reusable UI components (in the “components” directory) that build the interactive dashboard (tables, charts, dialogs, navigation, date pickers, etc.).
- API & Webhook Handlers – Illustrate the server-side endpoints such as the API routes in “app/api/webhook” (and other API endpoints if applicable) that manage external events like webhook data.
- Business Logic / Actions – Include the “actions” folder which contains domain-specific logic (for donations and donors). This indicates separation of core business concerns from view code.
- Data Access Layer – Indicate the database and schema management. Represent the “drizzle” folder (with SQL migration files and snapshots) along with the “src/db” directory where the DB connection and schema definitions reside.
- Utility & Library Code – Optionally note the helper functions and libraries (e.g., in “lib”, “hooks”, and “types”) that support the application behavior.

##### Relationships and Interactions
- Data Flow: Show how the client interacts with the server through Next.js pages. The UI components call business actions (donations.action.ts, donors.action.ts) and, through API endpoints, communicate with external services (e.g., webhooks) or the data access layer.
- Database Interaction: Demonstrate connections between the API/Business Logic and the database layer (managed by Drizzle and schema definitions), including how migrations are applied from the “drizzle” folder.

##### Architectural Patterns and Technologies
- Next.js File-based Routing & App Directory: Emphasize the use of Next.js’s routing and layout features by noting directories such as “app/(authenticated)” for guarded content versus public pages.
- Component-Based UI: The extensive “components” directory shows a modular and reusable UI system that can be represented by grouped modules (Dashboard UI, Data Tables, Dialogs, etc.).
- Tools and Configurations: Optionally note the use of Prettier, ESLint, and custom hooks to indicate coding standards and custom behaviors.

##### Final Recommendations
- A high-level perspective that emphasizes the separation between the main functional areas; detailed interactions at each layer (e.g., API request flows, rendering pipelines) can be documented separately if needed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["Client/Browser Interface (Next.js App)"]:::presentation
        Components["Frontend UI Components"]:::presentation
    end

    %% Server Layer
    subgraph "Server Layer"
        API["API & Webhook Handlers"]:::api
        Business["Business Logic / Actions"]:::business
    end

    %% Data Layer
    subgraph "Data Layer"
        Drizzle["Drizzle (Migrations)"]:::database
        DBSchema["DB Connection & Schema"]:::database
    end

    %% Utility & Library Code
    subgraph "Utility & Library Code"
        Lib["Library Code (lib)"]:::utility
        Hooks["Hooks (hooks)"]:::utility
        Types["Types (types)"]:::utility
    end

    %% External Systems
    subgraph "External Systems"
        Webhook["External Webhook Service"]:::external
    end

    %% Relationships - Presentation Flow
    UI -->|"integrates"| Components
    UI -->|"APIcalls"| API

    %% Relationships - Server Flow
    API -->|"invokeActions"| Business

    %% Relationships - Data Flow
    Business -->|"runsMigrations"| Drizzle
    Business -->|"queriesDB"| DBSchema

    %% External Integration
    Webhook -->|"sendsData"| API

    %% Utility Support (dotted lines)
    Lib -.->|"supports"| UI
    Hooks -.->|"supports"| UI
    Types -.->|"supports"| UI

    Lib -.->|"supports"| Business
    Hooks -.->|"supports"| Business
    Types -.->|"supports"| Business

    %% Click Events
    click UI "https://github.com/aclovestech/contributrack/tree/main/app/"
    click Components "https://github.com/aclovestech/contributrack/tree/main/components/"
    click API "https://github.com/aclovestech/contributrack/tree/main/app/api/webhook/"
    click Business "https://github.com/aclovestech/contributrack/tree/main/actions/"
    click Drizzle "https://github.com/aclovestech/contributrack/tree/main/drizzle/"
    click DBSchema "https://github.com/aclovestech/contributrack/tree/main/src/db/"
    click Lib "https://github.com/aclovestech/contributrack/tree/main/lib/"
    click Hooks "https://github.com/aclovestech/contributrack/tree/main/hooks/"
    click Types "https://github.com/aclovestech/contributrack/tree/main/types/"

    %% Styles
    classDef presentation fill:#e0f7fa,stroke:#00796b,stroke-width:2px;
    classDef api fill:#ffecb3,stroke:#f57f17,stroke-width:2px;
    classDef business fill:#fce4ec,stroke:#c2185b,stroke-width:2px;
    classDef database fill:#e8f5e9,stroke:#388e3c,stroke-width:2px;
    classDef utility fill:#e3f2fd,stroke:#1565c0,stroke-width:2px;
    classDef external fill:#fff9c4,stroke:#f9a825,stroke-width:2px;
```
