The 2020 Next.js rewrite, now being merged into impress!
Find a file
Matchu 299561d1e3 Paginate the user outfits page
My main inspiration for doing this is actually our potentially-huge upcoming Vercel bill lol

From inspecting my Honeycomb dashboard, it looks like the main offender for backend CPU time usage is outfit images. And it looks like they come in big spikes, of lots of low usage and then suddenly 1,000 requests in one minute.

My suspicion is that this is from users with many saved outfits loading their outfit page, which previously would show all of them at once.

We do have `loading="lazy"` set, but not all browsers support that yet, and I've had trouble pinning down the exact behavior anyway!

Anyway, paginating makes for a better experience for those huge-list users anyway. We've been meaning to do it, so here we go!

My hope is that this drastically decreases backend CPU hours immediately 🤞 If not, we'll need to investigate in more detail where these outfit image requests are actually coming from!

Note that I added the pagination to the existing `outfits` GraphQL endpoint, rather than creating a new one. I felt comfortable doing this because it requires login anyway, so I'm confident that other clients aren't using it; and because, while this kind of thing often creates a risk of problems with frontend and backend code getting out of sync, I think someone running old frontend code will just see only their first 30 outfits (but no pagination toolbar), and get confused and refresh the page, at which point they'll see all of them. (And I actually _prefer_ that slightly confusing UX, to avoid getting more giant spikes of outfit image requests, lol :p)
2021-11-01 19:33:40 -07:00
.github/workflows Fix GitHub Action for Sentry, attempt 6 2021-01-16 11:27:26 -08:00
.husky Add a pre-commit lint hook 2021-05-04 18:50:47 -07:00
.vscode update chakra imports 2020-12-25 09:08:33 -08:00
api Await closing Playwright before finish request 2021-09-03 15:43:27 -07:00
cypress Warn user of unsaved outfit changes 2021-05-04 16:31:48 -07:00
public Add HTML comment note to user script authors 2021-04-14 02:03:44 -07:00
scripts Use the first Auth0 connection instead of prompt 2021-10-02 01:01:29 -07:00
src Paginate the user outfits page 2021-11-01 19:33:40 -07:00
.gitignore upgrade to react-scripts 4.0.1 2020-12-28 13:47:09 -08:00
cypress.json Basic outfit state Cypress tests 2021-04-16 04:27:19 -07:00
LICENSE.md Add LICENSE.md 2021-01-21 05:55:57 -08:00
package.json Update @apollo/client 2021-09-30 18:37:09 -07:00
README.md update README to mention Rails app is gone 2020-09-04 04:09:01 -07:00
tsconfig.json Fix tsconfig.json error 2021-02-06 22:45:28 -08:00
vercel.json Use chrome-aws-lambda for assetImage 2021-08-19 16:27:22 -07:00
yarn.lock Update @apollo/client 2021-09-30 18:37:09 -07:00

Dress to Impress beach logo

Dress to Impress 2020

This is a rewrite of the Neopets customization app, Dress to Impress!

It's a React app, built with create-react-app, running on Vercel, JAMstack-style.

The motivating goals of the rewrite are:

  • Mobile friendly, to match Neopets's move to mobile.
  • Simple modern tech, to be more maintainable over time and decrease hosting costs.

If you want to contribute, please reach out to Matchu! This repository is almost shareable, but the main limitation is that we currently run even our development server against the production database, and those credentials are private. But we can change that if there's interest!

Architecture sketch

First, there's the core app, in this repository.

  • React app: Runs on Vercel's CDN. Code in src/app.
  • API functions: Run on Vercel's Serverless Functions. Code in api and src/server.

Then, there's our various data storage components.

  • MySQL database: Runs on our Linode VPS, colocated with the old app.
  • Amazon S3: Stores PNGs of pet/item appearance layers, converted from the Neopets SWFs. (Once Neopets releases HTML5-compatible assets for all their items, we can hopefully remove this!)

Finally, there's our third-party integrations.

  • Auth0: For authentication. Data imported from our old OpenNeo ID auth database.
  • Honeycomb: For observability & performance insights on the backend.
  • Discord: For logging Support users' actions to a private Discord server.
  • Neopets: We load pet data from them! And plenty of assets!

Notable old components not currently included in Impress 2020:

  • Elasticsearch: Used for lightning-fast item search queries. So far, we're finding the MySQL queries to be fast enough in practice. Might consider using some kind of fulltext query engine if that doesn't scale with more users!
  • Resque: Used to schedule background tasks for modeling and outfit thumbnails.
  • Outfit thumbnail generation: Used for outfit thumbnails in the app. I'm wondering if there's a way to get away with not doing this, like just rendering the layers... but I suppose if we want a good social share experience, then we'll probably want this. Maybe we can generate them on the fly as API requests, instead of adding a data storage component?
  • Memcache: Used to cache common HTML and JSON snippets. Not yet needing anything similar in Impress 2020!
  • The entire old Rails app! No references to it in here, aside from some temporary URL links to features that aren't implemented here yet.