Project · Intermediate · about 16 hours
A fast catalogue with MongoDB and a Redis cache
Model food products as documents, index them for real queries, add a cache in front, and prove the speed-up with a load test and numbers.
Skills:NoSQL databases, Monitoring and observability, REST APIs and HTTP, Automated testing
Part of: Software Engineer (Backend)
Data and licences
- Open Food Facts product database ↗Open Database License (ODbL); images CC BY-SA
Brief
Product pages are read far more often than products change, and a few products get most of the traffic. That is the classic case for a document store plus a cache. Build it and measure it honestly.
What to build
Import products from one country of the Open Food Facts export into MongoDB. Decide what to embed (nutrition, labels) and what to reference.
Write down the three queries the product page needs. Create indexes for them and show
explain()before and after.Build the service with
GET /products/{barcode},GET /products?category=&nutriscore=andGET /products/{barcode}/similar.Add Redis cache-aside for product lookups with a TTL, delete keys on updates, and expose hits and misses as metrics.
Load test with a skewed key distribution (a few hot products). Report p50 and p95 latency and MongoDB operations per second, with and without the cache.
Deliverables
Repository with
service/,load/,indexes.md,REPORT.mdandcompose.yaml
How it is graded
Reviewers rerun your load test and change a product to check the cache is invalidated. The report must explain why the numbers are what they are.
Stretch
Protect against a cache stampede on a hot key and show the effect in a test.
Deliverables
- A MongoDB document model for products with the indexes your queries need, justified with explain() output
- A service (Java, Go or Python) with lookup, search and "similar products" endpoints
- A Redis cache-aside layer with TTLs, invalidation on updates and hit-rate metrics
- A load test report comparing p50 and p95 latency and database load with and without the cache
How a reviewer grades it
| Criterion | Weight | What good looks like |
|---|---|---|
| Document model and indexes fit the access patterns, shown with query plans | 30% | |
| Cache is correct (invalidation, TTL, no cross-user leakage) and observable | 25% | |
| Load test is fair and repeatable, with numbers and graphs | 25% | |
| Tests and README | 20% |