A system for tracking packages and delivery notifications across multiple carriers.
This Package Tracking System is designed to extract package details from emails automatically, sort them by delivery date, and notify users of upcoming deliveries. The system prioritizes object-oriented programming (OOP) principles and is implemented using JavaScript.
β‘ Key Features:
- Extracts package information (tracking number, shipping company, sender, delivery date) from emails.
- Organizes packages by delivery date and allows users to filter by status (Delivered, In Transit, Arriving Soon).
- Simulates notifications for upcoming deliveries.
- Enables users to categorize packages (Electronics, Clothing, Gift).
- Supports search and filtering by tracking number, sender, or category.
PROJECT1/
βββ docs/ # Documentation (JSDoc)
βββ src/
β βββ models/ # Data models
β β βββ Address.js # Address representation
β β βββ Carrier.js # Carrier abstraction
β β βββ Package.js # Package details
β β βββ ShipmentHistory.js # Package tracking history
β β βββ StatusUpdate.js # Status update representation
β β βββ Tag.js # Tags for categorization
β β βββ User.js # User entity
β β βββ UserPreferences.js # User preferences model
β βββ services/ # Business logic services
β β βββ EmailParser.js # Parses email for tracking details
β β βββ UserManager.js # Manages user authentication
β βββ main.js # Main CLI application
β βββ PackageTrackingSystem.js # Core package tracking logic
βββ CS5700 Project1.pdf # Business requirements, UML, mockups
βββ DESIGN_PRINCIPLES.md # OOP, SOLID, and design pattern documentation
βββ jsdoc.json # JSDoc configuration
βββ LICENSE.txt # License information
βββ package.json # Project dependencies
βββ README.md # Project documentation
# Clone the repository
git clone https://github.com/lacey1998/project1.git
cd project1
# Install dependencies
npm installnode src/main.jsOnce you start the CLI, you will see the following options:
=== π¦ Package Tracking System ===
1. Add package from email
2. Add hazmat package from email
3. Add international package from email
4. View all packages
5. Search packages
6. Filter by status
7. Add tag to package
8. Show notifications
9. Exit
==================================
The system provides three email simulations for testing:
- Regular Package Email (UPS) β Option
1 - Hazmat Package Email β Option
2 - International Package Email (DHL) β Option
3
These simulate receiving shipment notifications and extracting tracking details. Full email details can be viewed in main.js.
- Node.js β JavaScript runtime
- JSDoc β Documentation generation
- Object-Oriented Programming (OOP) β Encapsulation, Inheritance, Polymorphism
- SOLID Principles β Clean architecture design
- Design Patterns β Factory, Observer, Singleton
- Integration with real-time tracking APIs (FedEx, UPS, DHL).
- Actual email parsing implementation.
- User interface for better interaction.
This project is licensed under the MIT License.
Generative AI (ChatGPT) was consulted during development to enhance my understanding of software design principles, including the SOLID principles and design patterns, as well as for brainstorming child classes for the Carrier class.
"Explain the SOLID principles with examples in JavaScript."
β Response: ChatGPT provided explanations and examples for each SOLID principle, including good and bad examples to illustrate best practices.
- Single Responsibility Principle (SRP): Suggested refactoring classes that handle multiple concerns into smaller, focused classes.
- Open/Closed Principle (OCP): Recommended using abstraction to allow extensions without modifying existing code.
- Liskov Substitution Principle (LSP): Highlighted the need for subclasses to behave as expected when used in place of their parent class.
- Interface Segregation Principle (ISP): Suggested breaking large interfaces into smaller, specific ones.
- Dependency Inversion Principle (DIP): Encouraged using dependency injection to decouple high-level modules from low-level details.
"Explain the Factory, Observer, and Singleton design patterns with examples."
β Response: ChatGPT provided practical implementations for these patterns:
- Factory Pattern: Used to create
Carrierobjects dynamically based on the shipping provider. - Observer Pattern: Applied in the
NotificationSystemto notify users of package status updates. - Singleton Pattern: Ensured only one instance of
UserManagerexists.
π« Bad Example for Factory Pattern:
function createCarrier(type) {
let carrier;
if (type === "DHL") carrier = new DHL();
else if (type === "FedEx") carrier = new FedEx();
else throw new Error("Unknown carrier type");
return carrier;
}This approach lacks scalability as new carrier types require modifying this function, violating the Open/Closed Principle.
β Good Example for Factory Pattern:
class CarrierFactory {
static createCarrier(type) {
switch (type) {
case "DHL": return new DHL();
case "FedEx": return new FedEx();
default: throw new Error("Unknown carrier type");
}
}
}This implementation allows new carrier types to be added without modifying existing code.
"What is a good child class for the Carrier class that has unique attributes and methods?"
β Response: ChatGPT suggested child classes that already exist in the codebase:
- DHLInternational (for handling international shipments)
class DHLInternational extends Carrier {
constructor() {
super("DHL", /DHL\d{10}/);
this.internationalZones = [];
}
validateInternationalTracking(trackingNumber) {
return trackingNumber.startsWith("DHL");
}
}- HazmatCarrier (for hazardous material shipments)
class HazmatCarrier extends Carrier {
constructor() {
super("CHEMLOG", /HZ\d{8}/);
this.hazmatClasses = ["flammable", "corrosive", "radioactive"];
}
getHandlingInstructions(materialType) {
const instructions = {
"flammable": "Keep away from heat sources",
"corrosive": "Handle with protective gear",
"radioactive": "Special containment required"
};
return instructions[materialType] || "No special instructions";
}
}- It helps me understand the SOLID and design principles of OOP, I use some of ChatGPT's response plus my own finding to finish the Design_Principle.md
- The suggestions for the child class helps me introduce inheritence to my projects, I use ChatGPT's suggestion.