Skip to content

Enforce Daily Analysis Usage Limits for Free Users #2

Description

@Sumedh-6504

Description

Enforce the usage limit of 10 analyses per day for users on the "free" tier. When a user reaches this limit, block further uploads and prompt them to upgrade to the "pro" tier.

User Story

As a LexGuard administrator,
I want the system to count daily scans for free users,
So that we prevent API abuse and incentivize Pro tier conversions.

Technical Tasks

  • Write a helper function on the server to query how many documents a user has uploaded in the current calendar day.
  • Implement middleware or gatekeeper logic inside app/api/analyze/route.ts to check if user.plan === 'free' and total scans today >= 10.
  • If the limit is reached, return a 403 Forbidden response: { error: "Daily limit reached. Upgrade to Pro for unlimited analyses." }.
  • Add visual feedback in the upload page UI (app/(app)/upload/page.tsx) showing a progress bar of scans remaining today (e.g. "3 of 10 scans remaining today").

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions