# flaggigbo/green-initiatives architecture

> Architecture diagram of the GitHub repository flaggigbo/green-initiatives, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flaggigbo/green-initiatives
- Repository: https://github.com/flaggigbo/green-initiatives

## Overview

Berry Bank Green Hub is an environmental project-management and donation platform. The main user journey is to browse projects, view project details, and support projects; entities can create and manage projects, while admins approve them. The client uses React and Redux, and the Express API handles domain requests backed by MongoDB. Separate capabilities include authentication, comments, and bank-linked round-up donations. Some frontend and API implementation files were not excerpted, so uncertain client-to-server connections are shown as unverified rather than asserted.

Main entry points: [`server/routes/index.ts`](https://github.com/flaggigbo/green-initiatives/blob/main/server/routes/index.ts) (API routes), [`server/mongo/storage.ts`](https://github.com/flaggigbo/green-initiatives/blob/main/server/mongo/storage.ts) (Data access), [`server/controllers/roundup.controller.ts`](https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/roundup.controller.ts) (Round-up handling), [`client/src/pages`](https://github.com/flaggigbo/green-initiatives/tree/main/client/src/pages) (Project pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["React app<br/>[App.tsx]"]
  node_pages["Project pages"]
  node_clientstate["Redux state<br/>[store.ts]"]
  node_projectclient["Project client<br/>[projectService.ts]"]
  node_commentclient["Comment client<br/>[commentService.ts]"]
  node_roundupclient["Round-up client<br/>[roundupService.ts]"]
end

subgraph group_api["API and domain"]
  node_routes["API routes<br/>[index.ts]"]
  node_projects["Project handling"]
  node_comments["Comment handling"]
  node_common["Common services"]
end

subgraph group_identity["Identity and access"]
  node_usercontroller["User handling<br/>[user.controller.ts]"]
  node_authservice["Auth service<br/>[auth.service.ts]"]
end

subgraph group_funding["Donations and round-ups"]
  node_roundupcontroller["Round-up handling"]
  node_payments["Payment service<br/>[payment.service.ts]"]
  node_roundupservice["Round-up service<br/>[roundup.service.ts]"]
end

subgraph group_persistence["Persistence"]
  node_storage["Data access<br/>[storage.ts]"]
  node_models["Mongo models<br/>[index.ts]"]
  node_database[("MongoDB<br/>[mongodb.ts]")]
  node_types["Domain schemas<br/>[schema-mongo.ts]"]
end

node_visitor(("User"))
node_teller["Bank-link provider"]

node_visitor -->|"uses"| node_app
node_app -.->|"routes to"| node_pages
node_app -->|"provides state"| node_clientstate
node_pages -.->|"requests projects"| node_projectclient
node_pages -.->|"requests comments"| node_commentclient
node_pages -.->|"requests round-ups"| node_roundupclient
node_projectclient -.->|"calls API"| node_routes
node_commentclient -.->|"calls API"| node_routes
node_roundupclient -.->|"calls API"| node_routes
node_routes -->|"dispatches"| node_projects
node_routes -->|"dispatches"| node_comments
node_routes -->|"dispatches"| node_usercontroller
node_routes -->|"dispatches"| node_roundupcontroller
node_routes -->|"dispatches"| node_common
node_usercontroller -->|"delegates to"| node_authservice
node_usercontroller -->|"reads and writes"| node_storage
node_projects -->|"reads and writes"| node_storage
node_comments -->|"reads and writes"| node_storage
node_comments -.->|"notifies"| node_roundupcontroller
node_roundupcontroller -->|"requests payments"| node_payments
node_roundupcontroller -->|"flushes balances"| node_roundupservice
node_roundupcontroller -->|"reads and writes"| node_storage
node_payments -->|"reads and writes"| node_storage
node_roundupservice -->|"reads and writes"| node_storage
node_payments -->|"delegates to"| node_roundupservice
node_roundupcontroller -.->|"links accounts"| node_teller
node_storage -->|"uses models"| node_models
node_models -->|"uses schemas"| node_types
node_storage -.->|"persists data"| node_database

click node_app "https://github.com/flaggigbo/green-initiatives/blob/main/client/src/app/App.tsx"
click node_pages "https://github.com/flaggigbo/green-initiatives/tree/main/client/src/pages"
click node_clientstate "https://github.com/flaggigbo/green-initiatives/blob/main/client/src/app/store.ts"
click node_projectclient "https://github.com/flaggigbo/green-initiatives/blob/main/client/src/features/projects/projectService.ts"
click node_commentclient "https://github.com/flaggigbo/green-initiatives/blob/main/client/src/features/comments/commentService.ts"
click node_roundupclient "https://github.com/flaggigbo/green-initiatives/blob/main/client/src/features/roundup/roundupService.ts"
click node_routes "https://github.com/flaggigbo/green-initiatives/blob/main/server/routes/index.ts"
click node_projects "https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/project.controller.ts"
click node_comments "https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/comment.controller.ts"
click node_common "https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/common.controller.ts"
click node_usercontroller "https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/user.controller.ts"
click node_authservice "https://github.com/flaggigbo/green-initiatives/blob/main/server/services/auth.service.ts"
click node_roundupcontroller "https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/roundup.controller.ts"
click node_payments "https://github.com/flaggigbo/green-initiatives/blob/main/server/services/payment.service.ts"
click node_roundupservice "https://github.com/flaggigbo/green-initiatives/blob/main/server/services/roundup.service.ts"
click node_storage "https://github.com/flaggigbo/green-initiatives/blob/main/server/mongo/storage.ts"
click node_models "https://github.com/flaggigbo/green-initiatives/blob/main/server/models/index.ts"
click node_database "https://github.com/flaggigbo/green-initiatives/blob/main/server/connect/mongodb.ts"
click node_types "https://github.com/flaggigbo/green-initiatives/blob/main/shared/schema-mongo.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_pages,node_clientstate,node_projectclient,node_commentclient,node_roundupclient,node_visitor toneBlue
class node_routes,node_projects,node_comments,node_common toneAmber
class node_usercontroller,node_authservice toneMint
class node_roundupcontroller,node_payments,node_roundupservice toneRose
class node_storage,node_models,node_database,node_types,node_teller toneIndigo
```

## Components

### Client experience

- [React app](https://github.com/flaggigbo/green-initiatives/blob/main/client/src/app/App.tsx): `client/src/app/App.tsx`
- [Project pages](https://github.com/flaggigbo/green-initiatives/tree/main/client/src/pages): `client/src/pages`
- [Redux state](https://github.com/flaggigbo/green-initiatives/blob/main/client/src/app/store.ts): `client/src/app/store.ts`
- [Project client](https://github.com/flaggigbo/green-initiatives/blob/main/client/src/features/projects/projectService.ts): `client/src/features/projects/projectService.ts`
- [Comment client](https://github.com/flaggigbo/green-initiatives/blob/main/client/src/features/comments/commentService.ts): `client/src/features/comments/commentService.ts`
- [Round-up client](https://github.com/flaggigbo/green-initiatives/blob/main/client/src/features/roundup/roundupService.ts): `client/src/features/roundup/roundupService.ts`

### API and domain

- [API routes](https://github.com/flaggigbo/green-initiatives/blob/main/server/routes/index.ts): `server/routes/index.ts`
- [Project handling](https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/project.controller.ts): `server/controllers/project.controller.ts`
- [Comment handling](https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/comment.controller.ts): `server/controllers/comment.controller.ts`
- [Common services](https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/common.controller.ts): `server/controllers/common.controller.ts`

### Identity and access

- [User handling](https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/user.controller.ts): `server/controllers/user.controller.ts`
- [Auth service](https://github.com/flaggigbo/green-initiatives/blob/main/server/services/auth.service.ts): `server/services/auth.service.ts`

### Donations and round-ups

- [Round-up handling](https://github.com/flaggigbo/green-initiatives/blob/main/server/controllers/roundup.controller.ts): `server/controllers/roundup.controller.ts`
- [Payment service](https://github.com/flaggigbo/green-initiatives/blob/main/server/services/payment.service.ts): `server/services/payment.service.ts`
- [Round-up service](https://github.com/flaggigbo/green-initiatives/blob/main/server/services/roundup.service.ts): `server/services/roundup.service.ts`

### Persistence

- [Data access](https://github.com/flaggigbo/green-initiatives/blob/main/server/mongo/storage.ts): `server/mongo/storage.ts`
- [Mongo models](https://github.com/flaggigbo/green-initiatives/blob/main/server/models/index.ts): `server/models/index.ts`
- [MongoDB](https://github.com/flaggigbo/green-initiatives/blob/main/server/connect/mongodb.ts): `server/connect/mongodb.ts`
- [Domain schemas](https://github.com/flaggigbo/green-initiatives/blob/main/shared/schema-mongo.ts): `shared/schema-mongo.ts`

### Other components

- **User**
- **Bank-link provider**

## Connections

- User → React app: uses
- React app → Project pages: routes to
- React app → Redux state: provides state (evidence: `client/src/app/App.tsx`)
- Project pages → Project client: requests projects
- Project pages → Comment client: requests comments
- Project pages → Round-up client: requests round-ups
- Project client → API routes: calls API
- Comment client → API routes: calls API
- Round-up client → API routes: calls API
- API routes → Project handling: dispatches (evidence: `server/routes/index.ts`)
- API routes → Comment handling: dispatches (evidence: `server/routes/index.ts`)
- API routes → User handling: dispatches (evidence: `server/routes/index.ts`)
- API routes → Round-up handling: dispatches (evidence: `server/routes/index.ts`)
- API routes → Common services: dispatches (evidence: `server/routes/index.ts`)
- User handling → Auth service: delegates to (evidence: `server/controllers/user.controller.ts`)
- User handling → Data access: reads and writes (evidence: `server/controllers/user.controller.ts`)
- Project handling → Data access: reads and writes (evidence: `server/controllers/project.controller.ts`)
- Comment handling → Data access: reads and writes (evidence: `server/controllers/comment.controller.ts`)
- Comment handling → Round-up handling: notifies
- Round-up handling → Payment service: requests payments (evidence: `server/controllers/roundup.controller.ts`)
- Round-up handling → Round-up service: flushes balances (evidence: `server/controllers/roundup.controller.ts`)
- Round-up handling → Data access: reads and writes (evidence: `server/controllers/roundup.controller.ts`)
- Payment service → Data access: reads and writes (evidence: `server/services/payment.service.ts`)
- Round-up service → Data access: reads and writes (evidence: `server/services/roundup.service.ts`)
- Payment service → Round-up service: delegates to (evidence: `server/services/payment.service.ts`)
- Round-up handling → Bank-link provider: links accounts
- Data access → Mongo models: uses models (evidence: `server/mongo/storage.ts`)
- Mongo models → Domain schemas: uses schemas (evidence: `server/models/index.ts`)
- Data access → MongoDB: persists data
