Description
As the community adds more items to AIAtlas, fetching all models at once via GET /api/models will lead to heavy database loads and sluggish client performance. We need to upgrade the model table and card views to use infinite scrolling powered by cursor-based pagination.
Expected Behavior
- Backend Upgrade: Modify the
GET /api/models endpoint to accept cursor and limit query parameters. Implement Prisma's cursor-based pagination (using take and skip: 1).
- Frontend Intersection Observer: Integrate the Intersection Observer API (or a library like
react-intersection-observer) at the bottom of the ModelTable and ModelCard grids.
- State Management: When the user scrolls to the bottom, automatically fetch the next batch of models and append them to the existing React state seamlessly.
- Loading States: Display the existing
Skeletons.tsx component while the next batch is being fetched over the network.
Constraints
- URL state (like
?provider=OpenAI) must remain functional and work in tandem with the infinite scroll pagination.
- Avoid offset-based pagination as it causes layout shifts and performance degradation on large datasets; stick to cursor-based.
Labels
enhancement, level3, performance, database
Description
As the community adds more items to AIAtlas, fetching all models at once via
GET /api/modelswill lead to heavy database loads and sluggish client performance. We need to upgrade the model table and card views to use infinite scrolling powered by cursor-based pagination.Expected Behavior
GET /api/modelsendpoint to acceptcursorandlimitquery parameters. Implement Prisma's cursor-based pagination (usingtakeandskip: 1).react-intersection-observer) at the bottom of theModelTableandModelCardgrids.Skeletons.tsxcomponent while the next batch is being fetched over the network.Constraints
?provider=OpenAI) must remain functional and work in tandem with the infinite scroll pagination.Labels
enhancement,level3,performance,database