Project Documentation Final
Project Documentation Final
SCIENCES DEPARTMENT OF
COMPUTER SCIENCE
Date: 12/04/2025
1. Introduction
Customers Collection
{
"customer_id": "I74lXDOfoqsp",
"customer_zip_code_prefix": 6020,
"customer_city": "goiania",
"customer_state": "GO"
}
Orders Collection
{
"order_id": "u6rPMRAYIGig",
"customer_id": "I74lXDOfoqsp",
"order_purchase_timestamp": "2017-11-18 12:29:57",
"order_approved_at": "2017-11-18 12:46:08"
}
{
"order_id": "u6rPMRAYIGig",
"product_id": "1slxdgbgWFax",
"seller_id": "3jwvL6ihC45G",
"price": 24.1,
"shipping_charges": 20.9
}
Payments Collection
{
"order_id": "u6rPMRAYIGig",
"payment_type": "credit_card",
"payment_installments": 2,
"payment_value": 155.77
}
Products Collection
{
"product_id": "1slxdgbgWFax",
"product_category_name": "toys",
"product_weight_g": 50,
"product_length_cm": 16,
"product_height_cm": 5,
"product_width_cm": 11
}
3. Functional Implementation Using MongoDB Compass
Each collection supports Create, Read, Update, and Delete operations performed directly
in Compass.
3.2 Projection
{
"customer_id": 1,
"customer_city": 1,
"_id": 0
}
3.3 Indexing
customer_id
order_id
product_id
payment_type
product_category_name
3.4 Aggregations
[ { "$group": {
_id: "$product_category_name",
avg_weight: { "$avg": "$product_weight_g" },
avg_length: { "$avg": "$product_length_cm" }
}} ]
4.1 Replication
Replication in MongoDB provides high availability by creating copies of the same data
on multiple servers. For this project, we configured a Replica Set consisting of one
primary and two secondary nodes.
Objective: Ensure data redundancy and availability in case of hardware failure or server
crash.
rs.status()
Benefits Observed:
sh.addShard("rs0/localhost:27017,localhost:27018,localhost:27019")
sh.enableSharding("ecommerceDB")
sh.status()
Benefits Observed:
6. Conclusion
This project successfully implements a highly available, scalable e-commerce system using
MongoDB Compass. From core CRUD operations to advanced aggregations, replication,
and sharding, all requirements were fulfilled through UI-based interactions—
demonstrating complete mastery of MongoDB in a distributed environment.
Appendix
Tools Used:
MongoDB (v8.0.5)
MongoDB Compass (GUI)
mongosh (for cluster setup only)
Environment:
Windows 10
Ports used: 27017 (primary), 27018, 27019 (secondaries), 27020 (mongos)