PropSpaceX Media Service

Centralized media management — chunked uploads, automatic Sharp optimization (WebP/AVIF), and a provider abstraction over AWS S3 and Cloudinary with metadata in MongoDB.

Node.jsTypeScriptAWS S3CloudinarySharpgRPC
GitHub
01

System Architecture

REQUESTPOST /media/uploadtracing
gRPCvariantsmetadataGateway / ServicesUpload requestsEDGEUpload APIMultipart · chunkedSVCgRPC ServerAsset lookupsSVCSharp OptimizerResize · WebP/AVIFSVCProvider RouterStorage abstractionSVCAWS S3Primary storageEXTCloudinaryCDN · transformsEXTMongoDBAsset metadataDATA

Uploads stream in as multipart chunks, get optimized by Sharp (resize, WebP/AVIF), and the provider router places them on S3 or Cloudinary. Asset metadata and variants are tracked in MongoDB for responsive delivery.

02

Database Design

SCHEMA3 tables · 2 relationshover a table
assetsMongoDB_idobjectIdoriginal_namestringmime_typestringsizenumberproviderenumproperty_idobjectIdcreated_atdatevariantsMongoDB_idobjectIdasset_idobjectIdlabelenumurlstringwidthnumberheightnumberformatstringupload_sessionsMongoDB_idobjectIdasset_idobjectIdstatusenumchunks_totalnumberchunks_donenumber

One asset fans out into size variants per provider; upload sessions track chunked transfers until completion.

03

Engineering Challenges

01

Image optimization

Automatic resizing and WebP/AVIF conversion cut delivery bandwidth by roughly 60% across listing photos.

02

Provider abstraction

One upload API in front of S3 and Cloudinary — providers can be switched per asset class without touching callers.

03

Large files

Chunked uploads and streaming processing keep memory flat for videos and high-resolution imagery.

04

Protected delivery

Signed URLs and CDN cache invalidation for assets that should not be publicly addressable.

04

Trade-offs & Decisions

ChoseOverBecause
SharpImageMagickNative libvips bindings are faster and lighter on memory inside Node workers.
Multi-providerS3 onlyCloudinary transforms are cheaper for derived variants; S3 stays the durable source of truth.
MongoDBPostgreSQLVariant arrays per asset map naturally to documents and match the property service stack.