Skip to content

Issue 6: Subscription APIs — Create & Fetch User Subscriptions #119

@ShubhamKumarSahu-svg

Description

@ShubhamKumarSahu-svg

This issue introduces the core backend APIs for SubSentry that allow users to:

  • Add new subscriptions
  • Fetch their existing subscriptions

Together, these APIs form the foundation of the entire dashboard, enabling all future features such as UI listing, analytics, and email ingestion.


🔧 APIs to Implement

1️⃣ Create Subscription

POST /api/subscriptions

Allows a user to add a new subscription to the system.

2️⃣ Fetch Subscriptions

GET /api/subscriptions

Returns all subscriptions that belong to the currently authenticated user.


📌 Expanded Description

You will implement two user-scoped APIs that interact with the Subscription schema:

  • The POST API should:

    • Accept subscription details
    • Validate required fields
    • Store the subscription in MongoDB
  • The GET API should:

    • Retrieve subscriptions
    • Ensure only the authenticated user’s data is returned
    • Provide a clean and predictable response structure

Both APIs must strictly respect user data isolation.


🎯 Why this issue exists

  • Establishes the backend foundation for the entire product
  • Enables frontend dashboard development
  • Teaches secure, user-scoped CRUD operations
  • Encourages clean controller–route architecture

✅ Key Expectations

  • Proper request validation for POST
  • Clear separation of controller and route logic
  • User-based filtering when fetching data
  • Meaningful HTTP status codes and error messages
  • Stable and readable JSON responses

🚫 What NOT to do

  • ❌ Do NOT allow unauthenticated access
  • ❌ Do NOT return subscriptions belonging to other users
  • ❌ Do NOT trust arbitrary or hardcoded user IDs
  • ❌ Do NOT mix analytics or frontend logic into this issue
  • ❌ Do NOT over-fetch unnecessary fields

🧪 Testing Expectations

Contributors should be able to demonstrate:

  • Successful subscription creation
  • Fetching only their own subscriptions
  • Correct handling of invalid or missing inputs

🏁 Outcome

After completing this issue:

  • The backend will fully support subscription creation and retrieval
  • The project will be ready for dashboard UI integration
  • Contributors will have implemented real-world REST API patterns

Metadata

Metadata

Assignees

No one assigned

    Labels

    Points: 30apibackendopen-for-allAny one can work on it without getting assigned, every PR can merge

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions