Databases

MongoDB

Document modeling, aggregations, and indexing for production MongoDB.

Advanced3+ yearsDatabases

MongoDB is the database I reach for when the data model is naturally hierarchical or evolves quickly — AI document metadata, NFC analytics events, multi-tenant configs. I design schemas with read patterns in mind, use indexes deliberately, and lean on the aggregation framework rather than pulling data into the app to crunch it.

My Journey

How I work with MongoDB

MongoDB has been my main NoSQL store across most of my Node.js and NestJS projects. I started with Mongoose schemas and progressed to native-driver usage when I needed full control over queries or bulk operations.

Schema design is where I spend the most time up front — denormalizing for read patterns, embedding when growth is bounded, referencing when it is not. I have learned the hard way that 'just throw it all in a document' becomes a bottleneck when access patterns evolve.

I rely heavily on the aggregation pipeline for reporting, analytics rollups, and joins between collections. I use compound indexes to make those pipelines fast and verify with `.explain()` rather than guessing.

Where I've Applied It

MongoDB across business domains

AI & Machine Learning Platforms

Stored document metadata, processing-job status, and extracted structured data — with aggregations driving the analytics dashboard.

NFC & Digital Identity

Captured per-tap analytics events and built rollup aggregations for daily/weekly dashboards.

Real Estate

Modeled listings with embedded media + denormalized agent info for fast list/detail reads.

Automotive Marketplace

Backed the inventory catalog with MongoDB; used aggregations to power dealer-level dashboards.

Problems Solved

Real issues I resolved using MongoDB

Turned a 9-second analytics page into a 400ms page

Problem

An NFC analytics dashboard was scanning a 50M-document events collection on every load, with no supporting indexes.

Solution

Designed a compound index keyed on `(tenantId, eventDate, profileId)`, rewrote the aggregation to use $match early, and added a pre-computed daily rollup collection refreshed by a scheduled job.

Impact

Dashboard load time dropped from ~9s to ~400ms, primary cluster CPU normalized, and the rollups made future reports trivial to add.

MongoDBAggregation PipelineIndexes

Fixed unbounded array growth that was breaking documents

Problem

An audit-log array was embedded inside a tenant document; some tenants hit the 16MB document size limit after months of activity.

Solution

Migrated audit logs to a separate collection with a reference to tenant id and a TTL index for retention. Backfilled in batches with bulk writes during off-peak hours.

Impact

Eliminated document-size errors entirely, brought storage growth under control, and made audit queries faster thanks to a focused index.

MongoDBBulk operationsTTL indexes

Stopped a runaway find() from melting the primary

Problem

An ad-hoc admin query without an index was running an unindexed collection scan, blocking reads and pushing replica lag.

Solution

Added the missing compound index, set `maxTimeMS` on all admin queries, and locked unindexed queries out of production via a code-review checklist + `.explain()` in dev.

Impact

Replica lag returned to baseline, no more incident pages from admin queries, and devs got faster feedback when they were about to ship something expensive.

MongoDBIndexesReplica sets
Related Skills

Often used together

Have a MongoDB project in mind?

I am open to full-time and contract work where MongoDBis core to the stack. Let's talk about what you are building.