Skip to content

add cron jobs and notification api#8

Merged
Remi561 merged 1 commit into
mainfrom
features/connected-to-frontend
Jun 25, 2026
Merged

add cron jobs and notification api#8
Remi561 merged 1 commit into
mainfrom
features/connected-to-frontend

Conversation

@Remi561

@Remi561 Remi561 commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added in-app notifications with a dedicated dashboard to view recent alerts and remove individual items.
    • Users can now receive reminder and expiration emails for subscriptions.
  • Bug Fixes

    • Improved notification and reminder settings handling for user accounts.
    • Updated background processing so subscription status and exchange-rate data stay current.

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
subly Ready Ready Preview, Comment Jun 25, 2026 1:08am

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 266a0018-2635-4063-8aa2-9828048adb56

📥 Commits

Reviewing files that changed from the base of the PR and between 9720d2f and 889a9d7.

⛔ Files ignored due to path filters (1)
  • server/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (14)
  • .vscode/settings.json
  • client/src/lib/utils.js
  • client/src/pages/dashboard/Notification.jsx
  • server/package.json
  • server/prisma/migrations/20260624230150_create_notification_model_and_updated_user_model/migration.sql
  • server/prisma/schema.prisma
  • server/server.js
  • server/src/config/env.js
  • server/src/controllers/notification.controller.js
  • server/src/jobs/sendExpired.js
  • server/src/jobs/sendReminder.js
  • server/src/jobs/syncRate.js
  • server/src/routes/notification.route.js
  • server/src/services/email.service.js

📝 Walkthrough

Walkthrough

Notification storage and endpoints are added, the dashboard now lists and deletes notifications, reminder emails are sent through Resend with notification records, expired subscriptions are marked in a job, a separate job syncs EUR exchange rates, and a VS Code setting hides Postman dotenv notifications.

Changes

Notifications and subscription messaging

Layer / File(s) Summary
Schema and migration
server/prisma/schema.prisma, server/prisma/migrations/.../migration.sql
User gains notification/reminder fields and a notifications relation, Subscription loses reminder columns, Notification is added in the schema and migration, and the enum Type block is reformatted.
Notification API
server/server.js, server/src/routes/notification.route.js, server/src/controllers/notification.controller.js
Authenticated notification routes are mounted, and the controller lists or deletes the current user's notifications.
Notification dashboard
client/src/lib/utils.js, client/src/pages/dashboard/Notification.jsx
fetchWithAuth() now points at the local API base URL, and the dashboard renders loading/error/empty states plus delete handling with React Query invalidation.
Reminder email flow
server/src/config/env.js, server/package.json, server/src/services/email.service.js, server/src/jobs/sendReminder.js
RESEND_API_KEY is added to env, resend is added as a dependency, reminder and expired email templates are added, and the reminder job sends emails and creates notification records for due subscriptions.
Expired subscription job
server/src/jobs/sendExpired.js
The job marks overdue ACTIVE subscriptions as EXPIRED and disconnects Prisma after completion.

Exchange rate synchronization

Layer / File(s) Summary
EUR rate sync job
server/src/jobs/syncRate.js
The job fetches EUR exchange rates from the external API and upserts them into the database on module load.

Sequence Diagram(s)

Notification dashboard flow

sequenceDiagram
  participant NotificationPage
  participant fetchWithAuth
  participant notificationRouter
  participant getNotification
  participant deleteNotification
  participant ReactQuery as React Query
  participant prismaNotification as prisma.notification

  NotificationPage->>fetchWithAuth: GET /api/notification
  fetchWithAuth->>notificationRouter: authenticated request
  notificationRouter->>getNotification: GET /
  getNotification->>prismaNotification: findMany(userId)
  prismaNotification-->>getNotification: notifications
  getNotification-->>NotificationPage: data, count, message

  NotificationPage->>fetchWithAuth: DELETE /api/notification/delete/:id
  fetchWithAuth->>notificationRouter: authenticated request
  notificationRouter->>deleteNotification: DELETE /delete/:id
  deleteNotification->>prismaNotification: findFirst(userId, id)
  deleteNotification->>prismaNotification: delete(id)
  deleteNotification-->>NotificationPage: success
  NotificationPage->>ReactQuery: invalidate ["notifications"]
Loading

Reminder email flow

sequenceDiagram
  participant sendReminder
  participant prismaUser as prisma.user
  participant sendReminderEmail
  participant Resend
  participant prismaNotification as prisma.notification

  sendReminder->>prismaUser: find users with ACTIVE subscriptions
  prismaUser-->>sendReminder: users
  sendReminder->>sendReminderEmail: due subscriptions
  sendReminderEmail->>Resend: emails.send(...)
  Resend-->>sendReminderEmail: email sent
  sendReminder->>prismaNotification: create due-count notification
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Remi561/Subly#5: Also changes client/src/lib/utils.js’s getApiBaseUrl(), which directly affects the request URL construction used by the client fetch helper.

Poem

I hopped through APIs under the moon,
Found notifications jingling a carrot tune.
I nibbled some mail and the rates in the rain,
Then bounced back home for a restart again.
🐰✨ Hop, send, refresh!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch features/connected-to-frontend

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Remi561 Remi561 merged commit ad53804 into main Jun 25, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant