A tool for managing auction item data in MongoDB with both CLI and API interfaces.
This CLI tool allows team members to easily:
- Seed MongoDB with sample auction items (CLI)
- Add and delete auction items (CLI)
- Search for items using various criteria (API)
- Find similar items (API)
Each auction item contains the following fields:
title: Name of the auction itemdescription: Detailed description of the itemstart_price: Initial bidding pricereserve_price: Minimum acceptable price for the item
- Node.js (v14 or higher)
- MongoDB (running locally on default port 27017)
- npm (Node Package Manager)
-
Clone this repository:
git clone https://github.com/AndyGuffey/mongo-auction-cli.git cd mission-05 -
Install dependencies:
npm install
-
Ensure MongoDB is running on your local machine:
# Check if MongoDB is running mongod --version # Start MongoDB if needed (commands may vary by OS) brew services start mongodb-community # macOS with Homebrew sudo systemctl start mongod # Linux with systemd
You can optionally install this CLI tool globally to use the commands from any directory on your system.
# Clone the repository
git clone https://github.com/AndyGuffey/mongo-auction-cli.git
cd mission-05
# Install globally
npm install -g .# Navigate to the project directory
cd path/to/mission-05
# Install globally
npm install -g .Once installed globally, you can run these commands from any directory:
auction seed # Seed the database with sample items
auction add # Add a new auction item
auction delete # Delete an auction itemThis makes it easier to manage your auction database without needing to navigate to the project directory each time.
To uninstall the global command:
npm uninstall -g mission-05npm run seed
npm run add
npm run deleteauction seed
auction add
auction deletePopulate the database with sample auction items:
npm run seed
# or
node commands.js seedThis command will:
- Connect to MongoDB
- Clear any existing items in the database
- Insert sample auction items
- Create text indexes for search functionality
Add a new auction item to the database:
npm run add
# or
node commands.js addThis command will:
- Prompt you for the item details (title, description, start price, reserve price)
- Validate your input
- Add the new item to the database
Delete an auction item from the database:
npm run delete
# or
node commands.js deleteThis command will:
- Show a list of all available items
- Let you select which item to delete
- Ask for confirmation before deletion
To see all available commands:
npm start
# or
node commands.jsStart the API server:
npm run server # Standard mode
npm run dev # Development mode with auto-restarthttp://localhost:3000/Retrieve all auction items from the database
GET http://localhost:3000/api/itemsExample Response:
[
{
"_id": "65f583a7c390d3e426a6b8b1",
"title": "Surfboard",
"description": "The best surfboard ever",
"start_price": 100,
"reserve_price": 500
},
...
]Search for items using text search across title and description.
GET http://localhost:3000/api/items/search?query=surfboardFind items within a specific price range.
GET http://localhost:3000/api/items/price?min=100&max=600
GET http://localhost:3000/api/items/price?min=500
GET http://localhost:3000/api/items/price?max=200Discover items similar to a specific item based on text similarity.
GET http://localhost:3000/api/items/similar/65f583a7c390d3e426a6b8b1- Node.js
- MongoDB & Mongoose
- Commander.js (for CLI commands)
- Express.js (for API server)
- CORS (for API access control)
- Chalk (for colored console output)
- Inquirer (for interactive prompts)
- ES Modules
After running seed, add, or delete commands, you can verify changes in MongoDB Compass:
- Open MongoDB Compass and connect to:
mongodb://localhost:27017 - Navigate to the mission05 database
- Click on the items collection
- You should see all your auction items displayed in the GUI
- Add complete CRUD operations to the API
- Implement authentication for secure API access
- Add pagination for large result sets
- Integrate advanced AI-assisted search capabilities