Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Product Data Seeder

A Java 21 utility for generating and inserting test product data into MongoDB Atlas.

Purpose

Product Data Seeder was built as part of JavaLabs.io to generate a large dataset for testing REST API performance with APILoadGenAI.

It connects to MongoDB Atlas and inserts 10,000 generated products into the productdb.products collection.

Tech Stack

  • Java 21
  • Maven
  • MongoDB Atlas
  • MongoDB Java Driver
  • dotenv-java

Product Structure

Each generated product contains:

  • name
  • price

Example:

{
  "name": "Product-1",
  "price": 110.5
}

How It Works

Generate Products
       ↓
Create MongoDB Documents
       ↓
Batch with insertMany()
       ↓
MongoDB Atlas
       ↓
productdb.products

The seeder generates products from Product-1 through Product-10000 and inserts them using MongoDB's insertMany() operation.

Configuration

Create a .env file in the project root:

MONGODB_URI=your_mongodb_connection_string

The .env file is excluded through .gitignore and should never be committed.

Running the Seeder

Compile:

mvn compile

Run:

mvn exec:java "-Dexec.mainClass=com.javalabs.seeder.ProductDataSeeder"

The utility connects to MongoDB Atlas and inserts the generated product dataset into the products collection.

Why I Built This

APILoadGenAI needs a sufficiently large dataset to test how a REST API behaves under load.

Instead of manually creating thousands of products through Postman, this utility provides a simple way to generate test data programmatically.

The resulting dataset is used by ProductAPI as the backend target for APILoadGenAI performance experiments.

JavaLabs.io

Part of JavaLabs.io, a collection of Java-first experiments focused on building and understanding backend systems.

About

A Java 21 utility for generating and inserting test product data into MongoDB Atlas.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages