ShoeLab is a command-line interface (CLI) application designed to help athletes manage their running and hiking shoes. Built with Node.js, it leverages object-oriented programming (OOP) principles to generate, recommend, and track shoe usage based on user profiles, terrains, and activity levels. The application provides an interactive experience with colorful output, progress spinners, wear-level visualizations, and ASCII charts.
- User Profile Creation: Initialize an athlete profile with name, foot size, preferred terrain, activity level, and shoe type.
- Shoe Generation: Generate random running shoes and hiking boots with varied brands, models, sizes, and materials.
- Shoe Recommendations: Receive personalized shoe recommendations based on your profile, terrain, and activity level.
- Run Tracking: Log runs to track shoe wear, durability, and performance, with visual wear-level indicators.
- Shoe Deletion: Remove shoes from your collection.
- Statistics: View run history, total distance, and shoe wear with ASCII charts.
- Data Persistence: Save profiles, shoes, and run data as JSON files for seamless session continuity.
- Unit Testing: Includes comprehensive unit tests using Jest to ensure reliability of core components.
- Interactive CLI: Enjoy a user-friendly interface with animations, spinners, and clear prompts.
-
Prerequisites:
- Node.js (v14 or higher)
- npm (included with Node.js)
-
Clone the Repository:
git clone <repository-url> cd shoelab
-
Install Dependencies:
npm install
-
Run the Application:
node bin/shoelab.js
ShoeLab provides the following commands:
Command | Description | Example |
---|---|---|
init |
Create or load a user profile | node bin/shoelab.js init |
generate |
Generate a set of shoes | node bin/shoelab.js generate |
recommend |
Get personalized shoe recommendations | node bin/shoelab.js recommend |
run |
Log a run and track shoe wear | node bin/shoelab.js run |
delete |
Delete a shoe from your collection | node bin/shoelab.js delete |
stats |
Display run history and shoe statistics with charts | node bin/shoelab.js stats |
exit |
Exit the application | node bin/shoelab.js exit |
-
Initialize a Profile:
node bin/shoelab.js init
Follow prompts to enter your name, foot size, preferred terrain, and activity level.
-
Generate Shoes:
node bin/shoelab.js generate
Generate 10 shoes (5 running, 5 hiking) and optionally save them.
-
Get Recommendations:
node bin/shoelab.js recommend
View top 3 shoe recommendations and select one to use.
-
Log a Run:
node bin/shoelab.js run
Enter the distance ran and view updated shoe durability and wear level.
-
View Statistics:
node bin/shoelab.js stats
See total distance, run history, shoe stats, and ASCII charts for wear levels and run distances.
-
Delete a Shoe:
node bin/shoelab.js delete
Choose a shoe to remove from your collection.
ShoeLab includes unit tests for core components using Jest. The tests cover:
- RecommendationEngine: Scoring and ranking shoes based on athlete profiles.
- PerformanceTracker: Run tracking, wear level calculations, and run statistics.
- Utilities: File I/O (
FileManager
), input validation (validateInput
), and shoe revival (reviveShoes
).
-
Ensure dependencies are installed:
npm install
-
Run the tests:
npm test
This executes all test files in the
__tests__
directory and displays pass/fail results. -
View coverage (optional):
npm test -- --coverage
shoelab/
├── __tests__/
│ ├── RecommendationEngine.test.js # Tests for shoe recommendation logic
│ ├── PerformanceTracker.test.js # Tests for run tracking and wear calculations
│ ├── FileManager.test.js # Tests for JSON file I/O
│ ├── validateInput.test.js # Tests for input validation
│ ├── reviveShoes.test.js # Tests for restoring shoe objects
shoelab/
├── __tests__/ # Unit tests for core components
├── classes/
│ ├── AthleteProfile.js # User profile management
│ ├── PerformanceTracker.js # Tracks runs and shoe wear
│ ├── RecommendationEngine.js # Generates shoe recommendations
│ ├── Shoe.js # Abstract base shoe class
│ ├── RunningShoe.js # Running shoe subclass
│ ├── HikingBoot.js # Hiking boot subclass
│ ├── ShoeFactory.js # Generates random shoes
│ ├── ShoeTypes.js # Shoe type registry
├── utils/
│ ├── askQuestion.js # Handles user input
│ ├── FileManager.js # Manages JSON file I/O
│ ├── getActiveUser.js # Retrieves active user data
│ ├── loadExistingUserData.js # Loads existing profiles
│ ├── LoadShoeData.js # Manages shoe data persistence
│ ├── loadUserContext.js # Centralizes user data loading
│ ├── reviveShoes.js # Restores shoe objects
│ ├── validateInput.js # Validates user inputs
│ ├── visualizeWearLevel.js # Visualizes shoe wear
├── data/ # Stores JSON data (profiles, shoes, tracker)
├── bin/
│ ├── shoelab.js # Main CLI application
├── package.json # Project dependencies
commander
: CLI command parsingchalk
: Colorful console outputora
: Progress spinnerschalk-animation
: Animated console textasciichart
: ASCII charts for statisticsjest
: Unit testing framework (dev dependency)
Install dependencies using:
npm install commander chalk ora chalk-animation asciichart
npm install --save-dev jest
To contribute or modify the project:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/your-feature
). - Make changes and commit (
git commit -m "Add your feature"
). - Run tests to ensure functionality (
npm test
). - Push to the branch (
git push origin feature/your-feature
). - Open a pull request.
- Enhance Calculation Precision for Real-World Use ( Strava, Garmin)
- Replace Dummy Shoes with Real Brand Models via API ( dont forget to add falback logic )
- Add Real User Accounts with MongoDB Integration ( bcrypt, jsonwebtoken, Mongoose )
- Enable Shoe Buying, Selling, and Visual Display ( probably i will give links for the product image, or there is a second option which is adding features to download to users device and give them path for the images location )
- Support Shoe Swapping and Renting
- Enhance recommendations with user feedback or external data.
- Add integration tests for CLI workflows.
MIT License. See LICENSE for details.
Built as a university OOP project to demonstrate object-oriented programming principles, including encapsulation, inheritance, polymorphism, and abstraction.
AI Assistance: This project utilized Grok 3, built by xAI, to assist with generating documentation, including this README