# gtbitsofgood/heart-of-passion architecture

> Architecture diagram of the GitHub repository gtbitsofgood/heart-of-passion, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gtbitsofgood/heart-of-passion
- Repository: https://github.com/gtbitsofgood/heart-of-passion

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js Pages & Components
- Client-side tRPC API Integration
- Theme System (Chakra UI + Tailwind)

b) Backend Layer:
- Next.js API Routes
- tRPC Routers
- Authentication System
- Database Models

c) Database Layer:
- MongoDB Instance
- Mongoose Models

##### Component Relationships

**[Client Browser] ←→ [Next.js Frontend] ←→ [tRPC API Layer] ←→ [MongoDB]**
- ↕
- [Google Auth Service]

##### Detailed Component Breakdown

Frontend Section:
- Backlog Management
- Calendar System
- Fundraising Planning
- User Management
- Expense Tracking
- Form Donations
- Chapter Management

API/Backend Section:
- TRPC routers:
- Chapter Router
- Donor Router
- Event Router
- Form Donations Router
- Fund Router
- Fundraiser Router
- Retreat Router
- User Router

Database Section:
- Mongoose models:
- Chapter
- Donor
- Event
- FormDonations
- Fund
- Fundraiser
- Retreat
- User
- Session
- UserKey

##### Implementation Details

Key implementation aspects:
- API route handling through Next.js
- tRPC procedure definitions
- Model relationships in MongoDB
- Authentication flow with sessions
- Frontend component hierarchy

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white

    %% Client
    Client[Client Browser]

    %% Frontend Layer
    subgraph FrontendLayer["Frontend Layer"]
        NextPages["Next.js Pages"]:::frontend
        NextComponents["Components"]:::frontend
        ThemeSystem["Theme System\nChakra UI + Tailwind"]:::frontend
        tRPCClient["tRPC Client"]:::frontend

        %% Feature Modules
        subgraph Features["Feature Modules"]
            Backlog["Backlog Management"]:::frontend
            Calendar["Calendar System"]:::frontend
            Fundraising["Fundraising Planning"]:::frontend
            UserMgmt["User Management"]:::frontend
            Expenses["Expense Tracking"]:::frontend
            FormDon["Form Donations"]:::frontend
            ChapterMgmt["Chapter Management"]:::frontend
        end
    end

    %% Backend Layer
    subgraph BackendLayer["Backend Layer"]
        APIRoutes["Next.js API Routes"]:::backend
        AuthSystem["Authentication System"]:::auth
        
        subgraph tRPCRouters["tRPC Routers"]
            ChapterRouter["Chapter Router"]:::backend
            DonorRouter["Donor Router"]:::backend
            EventRouter["Event Router"]:::backend
            FormDonRouter["Form Donations Router"]:::backend
            FundRouter["Fund Router"]:::backend
            FundraiserRouter["Fundraiser Router"]:::backend
            RetreatRouter["Retreat Router"]:::backend
            UserRouter["User Router"]:::backend
        end
    end

    %% Database Layer
    subgraph DatabaseLayer["Database Layer"]
        MongoDB[(MongoDB)]:::database
        
        subgraph Models["Mongoose Models"]
            ChapterModel["Chapter"]:::database
            DonorModel["Donor"]:::database
            EventModel["Event"]:::database
            FormDonModel["FormDonations"]:::database
            FundModel["Fund"]:::database
            FundraiserModel["Fundraiser"]:::database
            RetreatModel["Retreat"]:::database
            UserModel["User"]:::database
            SessionModel["Session"]:::database
            UserKeyModel["UserKey"]:::database
        end
    end

    %% External Services
    GoogleAuth["Google Auth Service"]:::auth

    %% Relationships
    Client <--> NextPages
    NextPages <--> NextComponents
    NextComponents --> ThemeSystem
    NextComponents <--> tRPCClient
    tRPCClient <--> APIRoutes
    APIRoutes <--> AuthSystem
    AuthSystem <--> GoogleAuth
    APIRoutes <--> tRPCRouters
    tRPCRouters <--> Models
    Models <--> MongoDB

    %% Click Events
    click NextPages "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/pages"
    click NextComponents "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/components"
    click ThemeSystem "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/theme"
    click tRPCClient "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/utils/api.ts"
    click APIRoutes "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/pages/api"
    click AuthSystem "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/auth.ts"
    click Backlog "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/components/Backlog"
    click Calendar "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/components/Calendar"
    click Fundraising "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/components/FundraisingPlanning"
    click UserMgmt "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/components/users"
    click Expenses "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/components/expenses"
    click FormDon "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/components/FormDonations"
    click ChapterMgmt "https://github.com/GTBitsOfGood/heart-of-passion/tree/staging/src/components/chapters"
    click ChapterRouter "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/api/routers/chapter.ts"
    click DonorRouter "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/api/routers/donor.ts"
    click EventRouter "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/api/routers/event.ts"
    click FormDonRouter "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/api/routers/formdonations.ts"
    click FundRouter "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/api/routers/fund.ts"
    click FundraiserRouter "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/api/routers/fundraiser.ts"
    click RetreatRouter "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/api/routers/retreat.ts"
    click UserRouter "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/api/routers/user.ts"
    click ChapterModel "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/models/Chapter.ts"
    click DonorModel "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/models/Donor.ts"
    click EventModel "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/models/Event.ts"
    click FormDonModel "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/models/FormDonations.ts"
    click FundModel "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/models/Fund.ts"
    click FundraiserModel "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/models/Fundraiser.ts"
    click RetreatModel "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/models/Retreat.ts"
    click UserModel "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/models/User.ts"
    click SessionModel "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/models/Session.ts"
    click UserKeyModel "https://github.com/GTBitsOfGood/heart-of-passion/blob/staging/src/server/models/UserKey.ts"
```
