Skip to content

Add lightweight /v1/approved-apps/marketplace endpoint#4288

Closed
smian1 wants to merge 1 commit intoBasedHardware:mainfrom
smian1:feature/marketplace-lightweight-endpoint
Closed

Add lightweight /v1/approved-apps/marketplace endpoint#4288
smian1 wants to merge 1 commit intoBasedHardware:mainfrom
smian1:feature/marketplace-lightweight-endpoint

Conversation

@smian1
Copy link
Copy Markdown
Collaborator

@smian1 smian1 commented Jan 18, 2026

Summary

  • Add new /v1/approved-apps/marketplace endpoint that returns only 15 fields needed by web frontend
  • Excludes large external_integration field (~3MB) to keep response under Next.js 2MB cache limit
  • Reduces response size from ~2.5MB to ~500KB

Why

The current /v1/approved-apps endpoint returns ~2.5MB of data, exceeding Next.js's 2MB cache limit. This causes cache warnings and 429 rate limiting during builds.

Test plan

  • Endpoint returns valid JSON with all 15 expected fields
  • Response size verified at ~500-600KB
  • Web frontend works with new endpoint (separate PR)

Add a new endpoint that returns only the 15 fields needed by the web
frontend, excluding large fields like external_integration (~3MB) to
keep response size under Next.js 2MB cache limit.

This reduces response size from ~2.5MB to ~500KB, fixing cache warnings
and 429 rate limiting during Next.js builds.
Copilot AI review requested due to automatic review settings January 18, 2026 23:52
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new lightweight endpoint, /v1/approved-apps/marketplace, to provide a smaller data payload for the web frontend, which is a great optimization to stay within Next.js's cache limits. The implementation is straightforward and aligns with existing patterns in the router. My review includes one high-severity suggestion to improve the maintainability and robustness of the new endpoint by leveraging Pydantic's serialization capabilities instead of manually constructing a dictionary.

Comment thread backend/routers/apps.py
Comment on lines +380 to +400

return [
normalize_app_numeric_fields({
'id': app.id,
'name': app.name,
'description': app.description,
'author': app.author,
'image': app.image,
'category': app.category,
'capabilities': list(app.capabilities),
'installs': app.installs,
'rating_avg': app.rating_avg,
'rating_count': app.rating_count,
'created_at': app.created_at,
'is_paid': app.is_paid,
'price': app.price,
'payment_plan': app.payment_plan,
'is_popular': app.is_popular,
})
for app in filtered_apps
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Manually creating a dictionary of app fields is brittle and hard to maintain. If the App model is updated in the future, this endpoint could easily become outdated or miss new fields, leading to potential bugs.

To make this more robust and maintainable, it's better to leverage Pydantic's serialization capabilities. Using model_dump with an include set ensures that you're explicitly selecting the fields you need, making the code cleaner and less prone to errors.

    fields_to_include = {
        'id', 'name', 'description', 'author', 'image', 'category',
        'capabilities', 'installs', 'rating_avg', 'rating_count', 'created_at',
        'is_paid', 'price', 'payment_plan', 'is_popular',
    }
    return [
        normalize_app_numeric_fields(
            app.model_dump(mode='json', include=fields_to_include)
        )
        for app in filtered_apps
    ]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new lightweight /v1/approved-apps/marketplace endpoint specifically optimized for the web marketplace. The endpoint returns only 15 essential fields needed by the frontend, explicitly excluding the large external_integration field (~3MB) that causes the original /v1/approved-apps endpoint to exceed Next.js's 2MB cache limit.

Changes:

  • New GET endpoint /v1/approved-apps/marketplace that returns a filtered subset of app fields
  • Reduces response payload from ~2.5MB to ~500KB by excluding unnecessary fields like external_integration
  • Maintains backward compatibility by keeping the original /v1/approved-apps endpoint unchanged

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/routers/apps.py
Comment on lines +371 to +372
@router.get('/v1/approved-apps/marketplace', tags=['v1'])
def get_marketplace_apps():
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endpoint lacks a response_model parameter in the decorator. While the existing /v1/approved-apps endpoint uses response_model=List[AppBaseModel], this new endpoint returns a custom dict structure. Consider either: 1) creating a dedicated Pydantic model for the marketplace response (e.g., MarketplaceApp) and using it as response_model, or 2) documenting why response_model is intentionally omitted if the custom dict structure is preferred.

Copilot uses AI. Check for mistakes.
@smian1
Copy link
Copy Markdown
Collaborator Author

smian1 commented Jan 18, 2026

@beastoin Here's what was tested:

Endpoint Verification:

  • ✅ Returns 200 OK
  • ✅ Returns ~180+ apps (same as original endpoint)
  • ✅ All 15 required fields present: id, name, description, author, image, category, capabilities, installs, rating_avg, rating_count, created_at, is_paid, price, payment_plan, is_popular

Response Size:

  • Before: ~2.5MB (exceeds Next.js 2MB cache limit)
  • After: ~500-600KB ✅

Pattern Compliance:

  • Uses normalize_app_numeric_fields() like all other app endpoints
  • Excludes personas with is_a_persona() check (same as /v1/approved-apps)

Pending:

  • Frontend PR will be submitted after this is deployed (just a one-line URL change)

@smian1
Copy link
Copy Markdown
Collaborator Author

smian1 commented Jan 19, 2026

@mdmohsin7 can you review.

@smian1 smian1 marked this pull request as draft January 19, 2026 08:06
@smian1 smian1 closed this Jan 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Hey @smian1 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our roadmap and vision

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community! 💜

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.

2 participants