← Back to projects

Case study

AssetPanda

AssetPanda is an asset management platform with barcode scanning, asset assignment and depreciation tracking. I worked on its backend at Webkorps and led the module covering permissions, search and data import/export.

  • NestJS
  • Node.js
  • DynamoDB
  • DynamoDB Streams
  • OpenSearch
  • Step Functions

Working with DynamoDB

The main data store is DynamoDB. It is fast when you read data by key, but filtering on other fields means scanning the table, and scans get slower and more expensive as the table grows. So for every feature we had to decide early whether it could work with the existing keys or needed its own index or data store.

Permissions

I built the user authorization and permissions module. Instead of loading records and then removing the ones a user isn't allowed to see, the API loads the user's permissions once at the start of the request and uses them to build the query. That way we only read the records the user can actually access, and pagination stays correct.

The check runs in one shared layer at the API level rather than inside each endpoint, so new endpoints get it automatically.

Search with OpenSearch

Users needed to search across many fields and sort by different columns, which DynamoDB doesn't handle well. We added OpenSearch for search and kept it in sync like this:

  1. A record is saved to DynamoDB.
  2. DynamoDB Streams picks up the change.
  3. A consumer updates the matching document in OpenSearch.

New records show up in search within a few seconds, and search queries don't add load to the main table. A few things we had to handle in the consumer:

  • Streams can deliver the same change more than once, so every index update writes the full document by id. Running it twice gives the same result.
  • Changes to the same record arrive in order, which is all a search index needs.
  • Streams keep data for 24 hours, so indexing errors have to be fixed within a day. Otherwise the index has to be rebuilt from scratch.

Since search updates a few seconds after a save, detail pages read directly from DynamoDB. A user who saves a record and opens it always sees the latest version. Failed index updates are retried, and anything that still fails goes to a dead letter queue so it can be replayed later. If OpenSearch has a problem, only search is affected. Saving data keeps working.

Import and export with Step Functions

If a bulk import runs as one long process, a single bad row can stop the whole job. I built the import and export workflows on AWS Step Functions instead. Each step has its own retry settings and error handling, so a bad record fails on its own and the rest of the job continues.

Step Functions also keeps a history for every run, showing which step failed, with what input and after how many retries. That makes a failed import much easier to look into.

Results

  • New data is searchable within seconds of being saved.
  • Search traffic doesn't touch the main DynamoDB table.
  • An OpenSearch outage only affects search, not saving data.
  • A bad row doesn't fail the whole import.
  • New API endpoints get permission checks by default.

Stack

  • NestJS
  • Node.js
  • DynamoDB
  • DynamoDB Streams
  • OpenSearch
  • Step Functions

Have questions about this project or working on something similar?

Get in touch