# algeriantechmakers/badir-core-web architecture

> Architecture diagram of the GitHub repository algeriantechmakers/badir-core-web, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/algeriantechmakers/badir-core-web
- Repository: https://github.com/algeriantechmakers/badir-core-web
- Video tour (about a minute): https://gitdiagram.com/algeriantechmakers/badir-core-web/video

## Overview

Badir is a community-initiative platform. Volunteers discover and filter initiatives, authenticate, complete profiles, join opportunities, and receive initiative updates; organizations publish and manage initiatives, while administrators approve organizations and initiatives. The sampled code shows Next.js routes delegating to services, Prisma persistence, Supabase file storage, and queued email/webhook processing. Some page-to-action wiring is inferred from documented capabilities and the tree; unsampled implementation links are omitted where ownership is uncertain.

Main entry points: [`lib/db.ts`](https://github.com/algeriantechmakers/badir-core-web/blob/main/lib/db.ts) (PostgreSQL Database), [`services/initiatives.ts`](https://github.com/algeriantechmakers/badir-core-web/blob/main/services/initiatives.ts) (Initiative Service), [`app/initiatives/page.tsx`](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/initiatives/page.tsx) (Initiative Screens), [`app/api/cron/process-post-emails/route.ts`](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/cron/process-post-emails/route.ts) (Post Email Worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_auth_ui["Auth Screens<br/>[page.tsx]"]
  node_initiative_ui["Initiative Screens<br/>[page.tsx]"]
  node_profile_ui["Profile Screens<br/>[page.tsx]"]
end

subgraph group_domain["Domain Services"]
  node_auth_api["Auth API<br/>[route.ts]"]
  node_initiative_api["Initiative API<br/>[route.ts]"]
  node_participation_api["Participation API<br/>[routes.ts]"]
  node_initiative_service["Initiative Service<br/>[initiatives.ts]"]
  node_participation_service["Participation Service<br/>[participations.ts]"]
  node_organization_service["Organization Service<br/>[organizations.ts]"]
  node_post_service["Post Service<br/>[posts.ts]"]
end

subgraph group_platform["Platform Data"]
  node_database[("PostgreSQL Database<br/>[db.ts]")]
  node_storage_service["Storage Helpers"]
  node_email_queue["Post Email Queue"]
end

subgraph group_operations["Administration"]
  node_admin_ui["Admin Dashboard<br/>[page.tsx]"]
  node_admin_service["Admin Service<br/>[admin.ts]"]
end

subgraph group_integrations["External Integrations"]
  node_email_api["Email API<br/>[route.ts]"]
  node_post_email_worker["Post Email Worker<br/>[route.ts]"]
  node_webhook_ingress["Newsletter Webhook<br/>[route.ts]"]
  node_webhook_worker["Webhook Worker<br/>[route.ts]"]
end

node_volunteer(("Volunteer"))
node_organization_actor(("Organization"))
node_admin_actor(("Administrator"))
node_mailerlite(("MailerLite"))
node_resend(("Resend"))
node_supabase(("Supabase Storage"))

node_volunteer -->|"signs in"| node_auth_ui
node_auth_ui -->|"authenticates"| node_auth_api
node_auth_api -->|"persists session"| node_database
node_volunteer -->|"discovers initiatives"| node_initiative_ui
node_initiative_ui -->|"requests listings"| node_initiative_api
node_initiative_api -->|"delegates query"| node_initiative_service
node_initiative_service -->|"reads initiatives"| node_database
node_volunteer -->|"joins initiative"| node_participation_api
node_participation_api -->|"records participation"| node_participation_service
node_participation_service -->|"writes participation"| node_database
node_volunteer -->|"updates profile"| node_profile_ui
node_profile_ui -->|"saves profile"| node_database
node_organization_actor -->|"creates initiative"| node_initiative_ui
node_initiative_ui -->|"submits initiative"| node_initiative_service
node_initiative_service -->|"stores initiative"| node_database
node_organization_actor -->|"uploads media"| node_storage_service
node_storage_service -->|"stores files"| node_supabase
node_admin_actor -->|"reviews submissions"| node_admin_ui
node_admin_ui -->|"applies decisions"| node_admin_service
node_admin_service -->|"updates approvals"| node_database
node_initiative_service -->|"manages posts"| node_post_service
node_post_service -->|"stores posts"| node_database
node_post_service -->|"queues notifications"| node_email_queue
node_post_email_worker -->|"fetches messages"| node_email_queue
node_post_email_worker -->|"loads post details"| node_database
node_post_email_worker -->|"sends batches"| node_resend
node_email_api -->|"sends email"| node_resend
node_mailerlite -.->|"posts events"| node_webhook_ingress
node_webhook_ingress -->|"queues events"| node_database
node_webhook_worker -->|"processes events"| node_database
node_webhook_worker -.->|"syncs status"| node_mailerlite

click node_auth_ui "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/(auth)/login/page.tsx"
click node_initiative_ui "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/initiatives/page.tsx"
click node_profile_ui "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/profile/page.tsx"
click node_admin_ui "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/admin/page.tsx"
click node_auth_api "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/auth/%5B...all%5D/route.ts"
click node_initiative_api "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/initiatives/route.ts"
click node_participation_api "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/participations/routes.ts"
click node_initiative_service "https://github.com/algeriantechmakers/badir-core-web/blob/main/services/initiatives.ts"
click node_participation_service "https://github.com/algeriantechmakers/badir-core-web/blob/main/services/participations.ts"
click node_organization_service "https://github.com/algeriantechmakers/badir-core-web/blob/main/services/organizations.ts"
click node_post_service "https://github.com/algeriantechmakers/badir-core-web/blob/main/services/posts.ts"
click node_admin_service "https://github.com/algeriantechmakers/badir-core-web/blob/main/services/admin.ts"
click node_database "https://github.com/algeriantechmakers/badir-core-web/blob/main/lib/db.ts"
click node_storage_service "https://github.com/algeriantechmakers/badir-core-web/blob/main/services/supabase-storage.ts"
click node_email_queue "https://github.com/algeriantechmakers/badir-core-web/blob/main/services/post-email-queue.ts"
click node_email_api "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/send-email/route.ts"
click node_post_email_worker "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/cron/process-post-emails/route.ts"
click node_webhook_ingress "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/webhooks/mailerlite/route.ts"
click node_webhook_worker "https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/cron/process-webhooks/route.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_auth_ui,node_initiative_ui,node_profile_ui toneBlue
class node_auth_api,node_initiative_api,node_participation_api,node_initiative_service,node_participation_service,node_organization_service,node_post_service,node_supabase toneAmber
class node_database,node_storage_service,node_email_queue toneMint
class node_admin_ui,node_admin_service toneRose
class node_email_api,node_post_email_worker,node_webhook_ingress,node_webhook_worker,node_volunteer,node_organization_actor,node_admin_actor,node_mailerlite,node_resend toneIndigo
```

## Components

### User Experience

- [Auth Screens](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/(auth)/login/page.tsx): `app/(auth)/login/page.tsx`
- [Initiative Screens](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/initiatives/page.tsx): `app/initiatives/page.tsx`
- [Profile Screens](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/profile/page.tsx): `app/profile/page.tsx`

### Domain Services

- [Auth API](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/auth/%5B...all%5D/route.ts): `app/api/auth/[...all]/route.ts`
- [Initiative API](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/initiatives/route.ts): `app/api/initiatives/route.ts`
- [Participation API](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/participations/routes.ts): `app/api/participations/routes.ts`
- [Initiative Service](https://github.com/algeriantechmakers/badir-core-web/blob/main/services/initiatives.ts): `services/initiatives.ts`
- [Participation Service](https://github.com/algeriantechmakers/badir-core-web/blob/main/services/participations.ts): `services/participations.ts`
- [Organization Service](https://github.com/algeriantechmakers/badir-core-web/blob/main/services/organizations.ts): `services/organizations.ts`
- [Post Service](https://github.com/algeriantechmakers/badir-core-web/blob/main/services/posts.ts): `services/posts.ts`

### Platform Data

- [PostgreSQL Database](https://github.com/algeriantechmakers/badir-core-web/blob/main/lib/db.ts): `lib/db.ts`
- [Storage Helpers](https://github.com/algeriantechmakers/badir-core-web/blob/main/services/supabase-storage.ts): `services/supabase-storage.ts`
- [Post Email Queue](https://github.com/algeriantechmakers/badir-core-web/blob/main/services/post-email-queue.ts): `services/post-email-queue.ts`

### Administration

- [Admin Dashboard](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/admin/page.tsx): `app/admin/page.tsx`
- [Admin Service](https://github.com/algeriantechmakers/badir-core-web/blob/main/services/admin.ts): `services/admin.ts`

### External Integrations

- [Email API](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/send-email/route.ts): `app/api/send-email/route.ts`
- [Post Email Worker](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/cron/process-post-emails/route.ts): `app/api/cron/process-post-emails/route.ts`
- [Newsletter Webhook](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/webhooks/mailerlite/route.ts): `app/api/webhooks/mailerlite/route.ts`
- [Webhook Worker](https://github.com/algeriantechmakers/badir-core-web/blob/main/app/api/cron/process-webhooks/route.ts): `app/api/cron/process-webhooks/route.ts`

### Other components

- **Volunteer**
- **Organization**
- **Administrator**
- **MailerLite**
- **Resend**
- **Supabase Storage**

## Connections

- Volunteer → Auth Screens: signs in
- Auth Screens → Auth API: authenticates
- Auth API → PostgreSQL Database: persists session
- Volunteer → Initiative Screens: discovers initiatives
- Initiative Screens → Initiative API: requests listings
- Initiative API → Initiative Service: delegates query
- Initiative Service → PostgreSQL Database: reads initiatives
- Volunteer → Participation API: joins initiative
- Participation API → Participation Service: records participation
- Participation Service → PostgreSQL Database: writes participation
- Volunteer → Profile Screens: updates profile
- Profile Screens → PostgreSQL Database: saves profile
- Organization → Initiative Screens: creates initiative
- Initiative Screens → Initiative Service: submits initiative
- Initiative Service → PostgreSQL Database: stores initiative
- Organization → Storage Helpers: uploads media
- Storage Helpers → Supabase Storage: stores files
- Administrator → Admin Dashboard: reviews submissions
- Admin Dashboard → Admin Service: applies decisions
- Admin Service → PostgreSQL Database: updates approvals
- Initiative Service → Post Service: manages posts
- Post Service → PostgreSQL Database: stores posts
- Post Service → Post Email Queue: queues notifications
- Post Email Worker → Post Email Queue: fetches messages
- Post Email Worker → PostgreSQL Database: loads post details
- Post Email Worker → Resend: sends batches
- Email API → Resend: sends email
- MailerLite → Newsletter Webhook: posts events
- Newsletter Webhook → PostgreSQL Database: queues events
- Webhook Worker → PostgreSQL Database: processes events
- Webhook Worker → MailerLite: syncs status
