How mrf-luckyboy/emailcollectmembership works
This is a Fastify service for tracking shared-subscription payments and sending personalized reminder emails. The primary workflow is to retrieve residents (or residents unpaid this month), generate tailored email content, send it through SMTP, and notify Telegram; admin endpoints also record payments and send a reminder to a selected resident. Monthly charge and follow-up jobs are documented capabilities. Their files are indexed as referencing the mail use case, but the excerpts do not show their invocation details, so those links are marked unverified.
Main entry points: send-mail.usecase.ts Reminder Use Case · routes.plugin.ts Route Wiring · admin.usecase.ts Admin Use Case · prisma.client.ts Prisma Client
Components 20
API and Admin
- Service Entry
src/index.ts - Fastify App
src/app.ts - Route Wiring
src/plugins/routes.plugin.ts - Admin Handler
src/handlers/admin.handler.ts - Manual Mail Handler
src/handlers/mail.handler.ts - Admin Use Case
src/application/usecases/admin.usecase.ts
Reminder Workflow
- Reminder Use Case
src/application/usecases/send-mail.usecase.ts - Charge Job
src/jobs/charge.job.ts - Follow-up Job
src/jobs/follow-up.job.ts - Email Templates
src/infrastructure/email/mailgen-template.adapter.ts
Persistence
- Resident Repository
src/infrastructure/database/resident.repository.ts - Payment Repository
src/infrastructure/database/paid.repository.ts - Prisma Client
src/infrastructure/database/prisma.client.ts - PostgreSQL
External Integrations
- Environment Config
src/pkg/config/config.ts - SMTP Sender
src/infrastructure/email/nodemailer.adapter.ts - SMTP Service
- Telegram Client
src/infrastructure/thirdparty/telegram.client.ts - Telegram API
Other components
- API Caller
Connections 29
- API Caller → Route Wiring: calls API
README.md - Service Entry → Fastify App: starts
src/index.ts - Fastify App → Route Wiring: registers
src/app.ts - Route Wiring → Admin Handler: routes admin
src/plugins/routes.plugin.ts - Route Wiring → Manual Mail Handler: routes manual mail
src/plugins/routes.plugin.ts - Route Wiring → Admin Use Case: constructs
src/plugins/routes.plugin.ts - Route Wiring → Reminder Use Case: constructs
src/plugins/routes.plugin.ts - Admin Handler → Admin Use Case: calls
src/handlers/admin.handler.ts - Manual Mail Handler → Reminder Use Case: calls
src/handlers/mail.handler.ts - Admin Use Case → Payment Repository: records payment
src/application/usecases/admin.usecase.ts - Admin Use Case → Resident Repository: gets resident
src/application/usecases/admin.usecase.ts - Admin Use Case → Email Templates: generates email
src/application/usecases/admin.usecase.ts - Admin Use Case → SMTP Sender: sends email
src/application/usecases/admin.usecase.ts - Reminder Use Case → Resident Repository: gets residents
src/application/usecases/send-mail.usecase.ts - Reminder Use Case → Email Templates: generates email
src/application/usecases/send-mail.usecase.ts - Reminder Use Case → SMTP Sender: sends email
src/application/usecases/send-mail.usecase.ts - Reminder Use Case → Telegram Client: notifies
src/application/usecases/send-mail.usecase.ts - Charge Job → Reminder Use Case: invokes
src/jobs/charge.job.ts - Follow-up Job → Reminder Use Case: invokes
src/jobs/follow-up.job.ts - Resident Repository → Prisma Client: queries
src/infrastructure/database/resident.repository.ts - Payment Repository → Prisma Client: uses client
- Prisma Client → PostgreSQL: reads and writes
- Route Wiring → Prisma Client: provides client
src/plugins/routes.plugin.ts - Prisma Client → Environment Config: reads connection
src/infrastructure/database/prisma.client.ts - Email Templates → Environment Config: reads image link
src/infrastructure/email/mailgen-template.adapter.ts - SMTP Sender → Environment Config: reads credentials
src/infrastructure/email/nodemailer.adapter.ts - SMTP Sender → SMTP Service: sends mail
src/infrastructure/email/nodemailer.adapter.ts - Telegram Client → Environment Config: reads settings
src/infrastructure/thirdparty/telegram.client.ts - Telegram Client → Telegram API: sends notification
src/infrastructure/thirdparty/telegram.client.ts