How oliver369x/volunteer_platform works
1. Overall shape
- This is a modular monolith API built with Node.js + Express for a volunteer assignment platform.
- The main request path is: HTTP client → route → middleware stack → controller → service → database/external service.
2. Application bootstrap
- src/server.js starts the process, and src/app.js wires the Express app.
- src/routes/index.js aggregates the module routers under the /api namespace.
- src/config/env.js and src/config/database.js centralize runtime configuration and DB connection setup.
3. Domain modules as bounded contexts
- The core business logic is split into feature modules under src/modules/: auth, users, profiles, organizations, tasks, matching, events, gamification, payments, reports, tracking, incidents, broadcasts, certificates, and audit.
- Each module follows the same pattern: controller + service + routes, and some include validators for request-level contract checks.
- For an architecture diagram, these modules should be shown as separate internal subsystems sharing the same database and infrastructure.
4. Cross-cutting request pipeline
- src/middlewares/ contains reusable concerns:
- auth for JWT-based authorization,
- validator for payload validation,
- error-handler for centralized API error mapping,
- request-context for per-request metadata,
- upload for file-upload handling.
- These sit between the router layer and the controllers, shaping the request before business logic runs.
5. Authentication and identity
- The auth module handles registration, login, and password reset.
- JWT helpers live in src/utils/jwt.js, password hashing in src/utils/password.js, and refresh-token persistence is modeled in the database.
- User identity is normalized across roles such as volunteers, organizations, and administrators.
6. Core operational workflows
- Organizations and volunteers are managed through organizations, users, and profiles.
- Tasks and assignments are the central operational objects: organizations create tasks, and the system assigns volunteers through the matching subsystem.
- Tracking, incidents, and broadcasts provide operational visibility and communication around active work.
7. AI matching subsystem
- src/modules/matching is the platform’s AI-assisted allocation engine.
- It combines local heuristics with the Gemini integration in src/services/gemini-client.js.
- The readme indicates a fallback mode: if GEMINI_API_KEY is absent, matching still works using only the heuristic path.
- The matching result is persisted as recommendation/assignment data, so the AI service is an augmentation layer, not the sole decision-maker.
8. Gamification and badge issuance
- src/modules/gamification handles assignment completion, point accumulation, reputation updates, and badge issuance.
- Supporting services include badge-generator.js and blockchain-simulator.js.
- The blockchain layer is explicitly simulated, so the architecture should show it as an emulated NFT/badge issuance boundary that can later be replaced with a real chain integration.
9. Payments, reporting, and certificates
- payments encapsulates monetization or transaction workflows; the repo includes Stripe-specific testing guidance, so Stripe is likely the external payment boundary.
- reports provides organization-level dashboards and volunteer KPIs, reading from operational data rather than a separate analytics stack.
- certificates and pdf-generator.js indicate document generation is part of the application layer, likely producing downloadable completion artifacts.
10. Persistence layer
- The runtime data model is centered on PostgreSQL, with entities such as user, organization, task, assignment, volunteer-profile, refresh-token, audit-log, point-transaction, badge, volunteer-badge, and ai-recommendation.
- The repository contains two database toolchains:
- src/database/ with models, associations, migrations, and seeders,
- prisma/ with Prisma schema, migrations, and seed scripts.
- For diagramming, treat this as a shared persistence boundary with overlapping migration/seed workflows rather than two separate apps.
11. External integrations and infrastructure
- The main external services are:
- Gemini for AI-assisted matching,
- Cloudinary for media/storage-related flows,
- Pinata for decentralized storage support,
- a notification service for outbound user/org communications,
- and likely Stripe for payment processing.
- These integrations are isolated under src/services/, keeping the module services as the orchestration layer and the vendor clients as adapters.
12. Auditability and observability
- src/modules/audit and audit-log persistence show that important actions are tracked explicitly.
- request-context plus the logger utility suggest request correlation and traceable business events are part of the architecture, which matters for operational and compliance flows.
13. Tooling, deployment, and verification
- The project is container-friendly via Dockerfile, with environment templates in env.example and env.production.example.
- Database lifecycle is supported by scripts for migration, seeding, and reset operations.
- Quality assurance includes Jest + Supertest tests in src/tests/ and a Postman collection for API exploration.
14. How to draw it
- A good architecture diagram would show:
- external clients hitting the Express API,
- the middleware boundary,
- internal feature modules,
- shared services for AI/storage/payments/docs,
- and a PostgreSQL persistence layer.
- Then add side-boundaries for Gemini, Cloudinary/Pinata, Stripe, and the blockchain simulator, all invoked indirectly through module services.
Main entry points: index.js API routes · database PostgreSQL · services Adapters · app.js App
Components 24
Entry & API
Process bootstrap, Express wiring, and route aggregation.
- Server · Process entrypoint.
src/server.js - App · Express application wiring.
src/app.js - API routes · Mounts module routers under the API namespace.
src/routes/index.js
Domain modules
Feature bounded contexts implemented as controller-service-route slices.
- Auth · Registration, login, and password reset flows.
src/modules/auth - Users · User lifecycle and role management.
src/modules/users - Profiles · Volunteer profile data and preferences.
src/modules/profiles - Organizations · Organization accounts and membership validation.
src/modules/organizations - Tasks · Task creation and assignment objects.
src/modules/tasks - Matching · Heuristics plus Gemini-assisted assignment recommendations.
src/modules/matching - Events · Event coordination and scheduling.
src/modules/events - Tracking · Operational visibility for active work.
src/modules/tracking - Incidents · Issue reporting and response workflows.
src/modules/incidents - Broadcasts · Outbound communications to users and organizations.
src/modules/broadcasts - Gamification · Points, reputation, and badge issuance.
src/modules/gamification - Certificates · Completion documents and PDFs.
src/modules/certificates - Payments · Monetization and transaction workflows.
src/modules/payments - Reports · Operational dashboards and KPIs.
src/modules/reports - Audit · Explicit action tracking and compliance events.
src/modules/audit
Shared infra
Cross-cutting middleware and vendor adapter services.
- Middleware · Auth, validation, upload, context, and error handling.
src/middlewares - Config · Environment and database configuration.
src/config - Adapters · Gemini, Cloudinary, Pinata, notifications, PDF, and blockchain simulation.
src/services
Persistence
Database models, migrations, and seed workflows.
- PostgreSQL · Central persistence boundary for domain entities.
src/database - Prisma · Schema, migrations, and seed workflow.
prisma - Sequelize · Models, associations, migrations, and seeders.
src/database
Connections 37
- Server → App: starts · Bootstraps the HTTP application.
- App → API routes: mounts · Registers API routes.
- App → Middleware: uses · Installs request pipeline and centralized errors.
- API routes → Auth: routes · Auth endpoints.
- API routes → Users: routes · User endpoints.
- API routes → Profiles: routes · Profile endpoints.
- API routes → Organizations: routes · Organization endpoints.
- API routes → Tasks: routes · Task endpoints.
- API routes → Matching: routes · Matching endpoints.
- API routes → Events: routes · Event endpoints.
- API routes → Tracking: routes · Tracking endpoints.
- API routes → Incidents: routes · Incident endpoints.
- API routes → Broadcasts: routes · Broadcast endpoints.
- API routes → Gamification: routes · Gamification endpoints.
- API routes → Certificates: routes · Certificate endpoints.
- API routes → Payments: routes · Payment endpoints.
- API routes → Reports: routes · Reporting endpoints.
- API routes → Audit: routes · Audit endpoints.
- Auth → Adapters: uses · Password, token, and external adapters.
- Users → PostgreSQL: reads/writes · Persists user records.
- Profiles → PostgreSQL: reads/writes · Persists volunteer profile data.
- Organizations → PostgreSQL: reads/writes · Persists organizations and memberships.
- Tasks → PostgreSQL: reads/writes · Persists tasks and assignments.
- Matching → Adapters: uses · Invokes Gemini and stores recommendations.
- Events → PostgreSQL: reads/writes · Persists event data.
- Tracking → PostgreSQL: reads/writes · Persists operational tracking.
- Incidents → PostgreSQL: reads/writes · Persists incident records.
- Broadcasts → Adapters: uses · Sends notifications through adapters.
- Gamification → Adapters: uses · Generates badges and simulates chain issuance.
- Gamification → PostgreSQL: reads/writes · Persists points and badges.
- Certificates → Adapters: uses · Produces PDF documents.
- Payments → Adapters: uses · Integrates with payment adapter boundary.
- Reports → PostgreSQL: reads · Builds dashboards from operational data.
- Audit → PostgreSQL: writes · Stores audit events.
- Config → PostgreSQL: configures · Initializes database connection and runtime settings.
- Prisma → PostgreSQL: manages · Alternative schema/migration toolchain.
- Sequelize → PostgreSQL: manages · Primary model/migration toolchain.