# joavl/mealfy architecture

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

- Interactive diagram: https://gitdiagram.com/joavl/mealfy
- Repository: https://github.com/joavl/mealfy

## Overview

Mealfy is a food-donation platform connecting donors, families, and NGOs. The documented active product is a React frontend backed by a Node/Express mock backend; its user journey includes authentication, finding families or communities, donating, and viewing impact. The tree also contains a substantial .NET implementation, shown as a separate backend branch rather than assumed to be the active runtime. Relationships are limited to those evidenced by the README or sampled source index and excerpts; some feature modules are present in the tree but their call wiring was not sampled.

Main entry points: [`src/App.tsx`](https://github.com/joavl/mealfy/blob/main/src/App.tsx) (Application routes), [`src/backend/services/authService.ts`](https://github.com/joavl/mealfy/blob/main/src/backend/services/authService.ts) (Authentication), [`src/context/AppContext.tsx`](https://github.com/joavl/mealfy/blob/main/src/context/AppContext.tsx) (Session and app state), [`src/backend/utils/storage.ts`](https://github.com/joavl/mealfy/blob/main/src/backend/utils/storage.ts) (Browser persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web experience"]
  node_webapp["Application routes<br/>[App.tsx]"]
  node_authpage["Sign-in<br/>[Auth.tsx]"]
  node_featurepages["Donation and impact views"]
  node_admin["Admin console<br/>[AdminRoutes.tsx]"]
end

subgraph group_frontend["Frontend services"]
  node_appstate["Session and app state<br/>[AppContext.tsx]"]
  node_authsvc["Authentication<br/>[authService.ts]"]
  node_familysvc["Family discovery<br/>[familyService.ts]"]
  node_localstore[("Browser persistence<br/>[storage.ts]")]
  node_firebaseauth["Firebase authentication<br/>[firebaseAuth.ts]"]
  node_firestore[("Firestore registrations")]
  node_api["HTTP API client<br/>[apiClient.ts]"]
end

subgraph group_node["Node mock backend"]
  node_nodeapi["Node API routes"]
  node_nodeauth["Node authentication<br/>[auth.service.ts]"]
  node_nodefamilies["Node family services"]
  node_mockdb[("JSON mock database<br/>[mock-db.ts]")]
end

subgraph group_dotnet[".NET backend"]
  node_dotnetapi[".NET API controllers<br/>[Controllers]"]
  node_dotnetauth[".NET authentication<br/>[AuthService.cs]"]
  node_dbcontext[("Entity data access<br/>[MealfyDbContext.cs]")]
end

node_user(("Donor or family"))
node_firebase[("Firebase")]

node_user -->|"uses"| node_webapp
node_webapp -->|"reads state"| node_appstate
node_webapp -->|"routes to"| node_featurepages
node_webapp -->|"routes to"| node_admin
node_webapp -->|"routes to"| node_authpage
node_authpage -->|"authenticates via"| node_appstate
node_appstate -->|"loads session"| node_authsvc
node_appstate -->|"persists state"| node_localstore
node_appstate -->|"loads communities"| node_familysvc
node_authsvc -->|"reads and writes"| node_localstore
node_authsvc -->|"uses"| node_firebaseauth
node_authsvc -->|"saves registrations"| node_firestore
node_authsvc -->|"calls API"| node_api
node_familysvc -->|"reads and writes"| node_localstore
node_familysvc -->|"saves registrations"| node_firestore
node_firebaseauth -.->|"verifies identity"| node_firebase
node_api -->|"gets token"| node_firebaseauth
node_api -->|"reads token"| node_localstore
node_nodeapi -->|"routes to"| node_nodeauth
node_nodeapi -->|"routes to"| node_nodefamilies
node_nodeauth -->|"reads and writes"| node_mockdb
node_nodefamilies -->|"reads and writes"| node_mockdb
node_dotnetapi -->|"uses data context"| node_dbcontext
node_dotnetauth -->|"persists users"| node_dbcontext

click node_webapp "https://github.com/joavl/mealfy/blob/main/src/App.tsx"
click node_authpage "https://github.com/joavl/mealfy/blob/main/src/pages/Auth.tsx"
click node_appstate "https://github.com/joavl/mealfy/blob/main/src/context/AppContext.tsx"
click node_authsvc "https://github.com/joavl/mealfy/blob/main/src/backend/services/authService.ts"
click node_familysvc "https://github.com/joavl/mealfy/blob/main/src/backend/services/familyService.ts"
click node_featurepages "https://github.com/joavl/mealfy/tree/main/src/pages"
click node_admin "https://github.com/joavl/mealfy/blob/main/src/admin/routes/AdminRoutes.tsx"
click node_localstore "https://github.com/joavl/mealfy/blob/main/src/backend/utils/storage.ts"
click node_firebaseauth "https://github.com/joavl/mealfy/blob/main/src/lib/firebaseAuth.ts"
click node_firestore "https://github.com/joavl/mealfy/blob/main/src/lib/firestoreCadastros.ts"
click node_api "https://github.com/joavl/mealfy/blob/main/src/api/apiClient.ts"
click node_nodeapi "https://github.com/joavl/mealfy/tree/main/backend/src/modules"
click node_nodeauth "https://github.com/joavl/mealfy/blob/main/backend/src/modules/auth/auth.service.ts"
click node_nodefamilies "https://github.com/joavl/mealfy/blob/main/backend/src/modules/families/families.service.ts"
click node_mockdb "https://github.com/joavl/mealfy/blob/main/backend/src/database/mock-db.ts"
click node_dotnetapi "https://github.com/joavl/mealfy/tree/main/server/src/Mealfy.Api/Controllers"
click node_dotnetauth "https://github.com/joavl/mealfy/blob/main/server/src/Mealfy.Infrastructure/Services/AuthService.cs"
click node_dbcontext "https://github.com/joavl/mealfy/blob/main/server/src/Mealfy.Infrastructure/Persistence/MealfyDbContext.cs"

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_webapp,node_authpage,node_featurepages,node_admin toneBlue
class node_appstate,node_authsvc,node_familysvc,node_localstore,node_firebaseauth,node_firestore,node_api,node_firebase toneAmber
class node_nodeapi,node_nodeauth,node_nodefamilies,node_mockdb toneMint
class node_dotnetapi,node_dotnetauth,node_dbcontext toneRose
class node_user toneIndigo
```

## Components

### Web experience

- [Application routes](https://github.com/joavl/mealfy/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in](https://github.com/joavl/mealfy/blob/main/src/pages/Auth.tsx): `src/pages/Auth.tsx`
- [Donation and impact views](https://github.com/joavl/mealfy/tree/main/src/pages): `src/pages`
- [Admin console](https://github.com/joavl/mealfy/blob/main/src/admin/routes/AdminRoutes.tsx): `src/admin/routes/AdminRoutes.tsx`

### Frontend services

- [Session and app state](https://github.com/joavl/mealfy/blob/main/src/context/AppContext.tsx): `src/context/AppContext.tsx`
- [Authentication](https://github.com/joavl/mealfy/blob/main/src/backend/services/authService.ts): `src/backend/services/authService.ts`
- [Family discovery](https://github.com/joavl/mealfy/blob/main/src/backend/services/familyService.ts): `src/backend/services/familyService.ts`
- [Browser persistence](https://github.com/joavl/mealfy/blob/main/src/backend/utils/storage.ts): `src/backend/utils/storage.ts`
- [Firebase authentication](https://github.com/joavl/mealfy/blob/main/src/lib/firebaseAuth.ts): `src/lib/firebaseAuth.ts`
- [Firestore registrations](https://github.com/joavl/mealfy/blob/main/src/lib/firestoreCadastros.ts): `src/lib/firestoreCadastros.ts`
- [HTTP API client](https://github.com/joavl/mealfy/blob/main/src/api/apiClient.ts): `src/api/apiClient.ts`

### Node mock backend

- [Node API routes](https://github.com/joavl/mealfy/tree/main/backend/src/modules): `backend/src/modules`
- [Node authentication](https://github.com/joavl/mealfy/blob/main/backend/src/modules/auth/auth.service.ts): `backend/src/modules/auth/auth.service.ts`
- [Node family services](https://github.com/joavl/mealfy/blob/main/backend/src/modules/families/families.service.ts): `backend/src/modules/families/families.service.ts`
- [JSON mock database](https://github.com/joavl/mealfy/blob/main/backend/src/database/mock-db.ts): `backend/src/database/mock-db.ts`

### .NET backend

- [.NET API controllers](https://github.com/joavl/mealfy/tree/main/server/src/Mealfy.Api/Controllers): `server/src/Mealfy.Api/Controllers`
- [.NET authentication](https://github.com/joavl/mealfy/blob/main/server/src/Mealfy.Infrastructure/Services/AuthService.cs): `server/src/Mealfy.Infrastructure/Services/AuthService.cs`
- [Entity data access](https://github.com/joavl/mealfy/blob/main/server/src/Mealfy.Infrastructure/Persistence/MealfyDbContext.cs): `server/src/Mealfy.Infrastructure/Persistence/MealfyDbContext.cs`

### Other components

- **Donor or family**
- **Firebase**

## Connections

- Donor or family → Application routes: uses (evidence: `README.md`)
- Application routes → Session and app state: reads state (evidence: `src/App.tsx`)
- Application routes → Donation and impact views: routes to (evidence: `src/App.tsx`)
- Application routes → Admin console: routes to (evidence: `src/App.tsx`)
- Application routes → Sign-in: routes to (evidence: `src/App.tsx`)
- Sign-in → Session and app state: authenticates via (evidence: `src/pages/Auth.tsx`)
- Session and app state → Authentication: loads session (evidence: `src/context/AppContext.tsx`)
- Session and app state → Browser persistence: persists state (evidence: `src/context/AppContext.tsx`)
- Session and app state → Family discovery: loads communities (evidence: `src/context/AppContext.tsx`)
- Authentication → Browser persistence: reads and writes (evidence: `src/backend/services/authService.ts`)
- Authentication → Firebase authentication: uses (evidence: `src/backend/services/authService.ts`)
- Authentication → Firestore registrations: saves registrations (evidence: `src/backend/services/authService.ts`)
- Authentication → HTTP API client: calls API (evidence: `src/backend/services/authService.ts`)
- Family discovery → Browser persistence: reads and writes (evidence: `src/backend/services/familyService.ts`)
- Family discovery → Firestore registrations: saves registrations (evidence: `src/backend/services/familyService.ts`)
- Firebase authentication → Firebase: verifies identity
- HTTP API client → Firebase authentication: gets token (evidence: `src/api/apiClient.ts`)
- HTTP API client → Browser persistence: reads token (evidence: `src/api/apiClient.ts`)
- Node API routes → Node authentication: routes to (evidence: `backend/src/modules/auth/auth.service.ts`)
- Node API routes → Node family services: routes to (evidence: `backend/src/modules/families/families.controller.ts`)
- Node authentication → JSON mock database: reads and writes (evidence: `backend/src/modules/auth/auth.service.ts`)
- Node family services → JSON mock database: reads and writes (evidence: `backend/src/modules/families/families.service.ts`)
- .NET API controllers → Entity data access: uses data context (evidence: `server/src/Mealfy.Api/Controllers/DonationsController.cs`)
- .NET authentication → Entity data access: persists users (evidence: `server/src/Mealfy.Infrastructure/Services/AuthService.cs`)
