How congminh2211/charityconnect works
1. Overall shape
CharityConnect is a role-based donor/organization/admin platform split into a single-page React frontend and four backend capabilities behind an Nginx API gateway. The backend is intentionally decomposed by domain: identity, campaigns, donations, and assistant/content verification. Each core service owns its own database and migrations; there is no shared cross-service database access.
2. Frontend as the user-facing shell
The frontend is a Vite + React + TypeScript app organized by feature area rather than by technical layer. It contains account, campaigns, donations, transparency, organization, admin, analytics, content, notifications, and engagement modules. AuthContext and AuthGuard enforce role-based access, while src/lib/api.ts switches between mock local data and real backend calls via VITE_USE_MOCK_API. This makes the UI usable both in demo mode and in full integrated deployment.
3. Public ingress and routing
In deployed mode, Nginx is the public edge. It serves the web app and proxies /api/v1 to the internal services. The README’s gateway mapping shows one public surface for the frontend, while backend services remain private. This keeps the architecture diagram clean: browser → gateway → domain services.
4. Identity service
backend/identity is a Node/Express service in TypeScript with PostgreSQL. Its code is split into auth, sessions, tokens, passwords, notifications, rate limiting, security, and account/profile management. It is the source of truth for login, registration, password reset, session handling, user profiles, Google Sign-In, and admin user management. It also sends account-related notifications and enforces security/rate controls.
5. Campaign service
backend/campaign is another Express/TypeScript service with its own database and state/stream/security/auth layers. It manages campaign lifecycle: organization-facing drafts, admin approval, financial plans, milestones, impact reports, and campaign state transitions. It also participates in Redis-stream-based integration events and exposes admin and organization endpoints for campaign moderation and reporting.
6. Donation service
backend/donation is a FastAPI/Python service backed by PostgreSQL. It handles donation creation, receipts, donor-facing histories, organization donation views, and transparency endpoints. Its domain layer and schema layer are separated from auth and diagnostics, which makes it the clearest place to show the financial/audit boundary in a diagram.
7. TrustChain and immutable ledger
Donation is the repository’s main integrity subsystem. It maintains a SHA-256 hash-chain in ledger_entries, where each entry depends on the previous hash, and it periodically aggregates hashes into Merkle roots for anchoring. The public payloads are designed to exclude sensitive donor identity data. This is not a blockchain network; it is an internal tamper-evident audit mechanism for receipts and ledger integrity.
8. Assistant and content verification
backend/assistant is a FastAPI service for the chatbot plus content verification/knowledge features. The code split (content_verify.py, knowledge.py, guides.py, main.py) suggests it serves both conversational assistance and public verification/content analysis endpoints. The README states it prefers internal CharityConnect knowledge first and only falls back to optional web search if configured with an AI provider. This service is also where public content verification pages in the frontend get their data.
9. Cross-service event flow
The main integrations are event-driven over Redis Streams, with idempotent event_id handling. A completed donation emits donation.completed, which Campaign consumes. Campaign can emit transparency.record, and Donation consumes FUND_USAGE_VERIFIED to update ledger/transparency state. This gives the system asynchronous propagation for financial and transparency state without coupling databases.
10. Data ownership and boundaries
Each service owns its schema and migrations (sql/001_... onward in each backend). The repo repeatedly enforces the rule that services do not query each other’s databases directly. All inter-service communication is through HTTP APIs or Redis events. That boundary is important for any architecture diagram: the databases should be drawn as service-private assets, not shared infrastructure.
11. External integrations
The system can connect to Google Sign-In, Gmail notifications, Anthropic/OpenAI for the assistant, and optional Sepolia anchoring for TrustChain. If these are not configured, the app falls back to local/demo behavior or internal simulation. Those integrations are optional but materially affect the deployment diagram because they introduce external trust boundaries and secret management.
12. Observability and operations
Prometheus scrapes service metrics and Grafana visualizes them. SonarQube is available as a quality profile in the Docker stack. CI is defined in GitHub Actions. These are supporting subsystems rather than business logic, but they belong in an ops layer in the diagram because they sit beside the runtime services and validate availability, quality, and code health.
13. Deployment topology
The repo supports two main modes: local/demo and full Dockerized stack. In local demo mode, the frontend can run alone with mock data. In full mode, Docker Compose brings up the web, gateway, three domain services, assistant, PostgreSQL instances, Redis, and observability tools. The frontend production build is static, while the backend services are independently deployable containers.
14. Role-driven product flow
The business flow is: organization applies and gets verified, creates and submits campaigns, admin approves campaigns, donors donate and receive receipts, organizations submit impact reports, and admins verify impact to update transparency ledgers. Public users can browse verified content, campaigns, statistics, and receipt verification without logging in. The diagram should therefore show both public read paths and authenticated role-specific write paths.
Main entry points: app.ts Campaign API · app/main.py Donation API · app/main.py Assistant API · nginx.conf Nginx
Components 23
Frontend
React single-page app and feature modules
- App Shell · SPA routing, layout, and role workspace
frontend/src/App.tsx - Auth UI · Login, registration, guards, and role context
frontend/src/auth/AuthContext.tsx - Feature Hub · User-facing modules for campaigns, donations, transparency, content, and admin
frontend/src/features - API Client · Switches between mock data and backend calls
frontend/src/lib/api.ts
Edge
Public ingress and routing
- Browser · Public and authenticated users of the platform
- Nginx · Serves the web app and proxies API traffic
nginx/nginx.conf - Redis Streams · Asynchronous cross-service events with idempotent handling
Identity
Auth, sessions, profiles, and notifications
- Identity API · Login, registration, sessions, tokens, profiles, and notifications
backend/identity/src/app.ts - Identity DB · Private identity data store and migrations
backend/identity/sql/001_init.sql
Campaigns
Campaign lifecycle and moderation
- Campaign API · Campaign drafts, approval, plans, milestones, and reporting
backend/campaign/src/app.ts - Campaign State · Lifecycle rules, moderation flow, and stream integration
backend/campaign/src/state.ts - Campaign DB · Private campaign data store and migrations
backend/campaign/sql/001_init.sql
Donations
Donation ledger and transparency
- Donation API · Donation creation, histories, receipts, and transparency views
backend/donation/app/main.py - TrustChain · Hash-chain and Merkle anchoring for tamper-evident receipts
backend/donation/app/trustchain.py - Donation DB · Private donation ledger and transparency tables
backend/donation/sql/001_init.sql
Assistant
Chatbot and content verification
- Assistant API · Chatbot, knowledge, and content verification endpoints
backend/assistant/app/main.py - Content Verify · Public content analysis and verification logic
backend/assistant/app/content_verify.py - Knowledge Base · CharityConnect knowledge-first answering and guidance
backend/assistant/app/knowledge.py
Ops
Observability and CI
- Prometheus · Scrapes service metrics
- Grafana · Operational dashboards and visualization
- CI · Automated tests and checks
.github/workflows/ci.yml
External
Optional third-party integrations
- Google Sign-In · Optional OAuth identity provider
- AI Providers · Optional Anthropic/OpenAI integrations
Connections 34
- Browser → Nginx: browse /api · Public users reach the platform through the edge
- Nginx → App Shell: serve SPA · Static frontend delivery
- Nginx → Identity API: proxy auth · API requests are routed to backend services
- Nginx → Campaign API: proxy campaigns · API requests are routed to backend services
- Nginx → Donation API: proxy donations · API requests are routed to backend services
- Nginx → Assistant API: proxy assistant · API requests are routed to backend services
- App Shell → Auth UI: role access · Auth context and guards gate role-specific views
- App Shell → Feature Hub: routes · Feature-oriented navigation inside the SPA
- Feature Hub → API Client: data access · Feature modules use the shared API adapter
- API Client → Identity API: auth calls · Login, sessions, profiles, and notifications
- API Client → Campaign API: campaign calls · Campaign browsing and moderation flows
- API Client → Donation API: donation calls · Donations, receipts, history, and transparency
- API Client → Assistant API: verify calls · Content verification and assistant requests
- Identity API → Identity DB: owns · Identity service owns its schema and migrations
- Campaign API → Campaign State: orchestrates · State machine and moderation flow
- Campaign API → Campaign DB: owns · Campaign service owns its schema and migrations
- Donation API → TrustChain: anchors · Tamper-evident ledger and Merkle aggregation
- Donation API → Donation DB: owns · Donation service owns its schema and migrations
- Assistant API → Content Verify: verifies · Public verification and analysis endpoints
- Assistant API → Knowledge Base: answers · Knowledge-first guidance and chatbot responses
- Campaign API → Redis Streams: emit/consume · Campaign integration events
- Donation API → Redis Streams: emit/consume · Donation completion and verification events
- Identity API → Google Sign-In: oauth · Optional Google Sign-In integration
- Assistant API → AI Providers: optional ai · Fallback external model and search integrations
- Prometheus → Identity API: scrape · Collects service metrics
- Prometheus → Campaign API: scrape · Collects service metrics
- Prometheus → Donation API: scrape · Collects service metrics
- Prometheus → Assistant API: scrape · Collects service metrics
- Grafana → Prometheus: visualize · Dashboards read metrics from Prometheus
- CI → App Shell: test · CI validates the frontend and services
- CI → Identity API: test · CI validates the frontend and services
- CI → Campaign API: test · CI validates the frontend and services
- CI → Donation API: test · CI validates the frontend and services
- CI → Assistant API: test · CI validates the frontend and services