Portobello Manager is a Java application designed to manage a second-hand store inventory. The system allows users to organize items into a hierarchical structure (categories containing products or sub-categories), calculate the total value of the inventory, and export the full catalog to a text file.
This project was developed as a final assignment to demonstrate proficiency in Object-Oriented Programming, Design Patterns, and core Java technologies.
- Hierarchical Organization: Create products and nest them inside categories and sub-categories.
- Total Calculation: Automatically calculate the total price of any category (recursive).
- Input Validation: Prevents invalid data (e.g., negative prices) using custom exceptions.
- Data Export: Saves the entire catalog structure into a flat file (
export_catalogo.txt).
The architecture is based on specific Design Patterns to ensure maintainability and scalability:
- Composite Pattern (
CatalogIteminterface,Product,Category):- Reason: Used to treat individual objects (Products) and compositions of objects (Categories) uniformly. This allows infinite nesting of categories.
- Factory Pattern (
CatalogFactory):- Reason: Centralizes object creation logic. It keeps the Main class clean and separates the instantiation logic from the business logic.
- Iterator Pattern (
StoreIterator):- Reason: Implemented to traverse the complex tree structure (categories inside categories) as a flat list. This is essential for printing the full list or exporting it to a file line-by-line.
- Exception Shielding (
CatalogException):- Reason: Custom checked exception used to handle specific domain errors (like negative prices) without crashing the application or showing raw stack traces to the user.
- Java SE 21: Core language.
- Maven: Dependency management and build automation.
- SLF4J / Logback: Professional logging framework.
- JUnit 5: Unit testing framework.
To run this project, you need JDK 21 and Maven installed.
-
Build the project:
mvn clean install
-
Run Tests:
mvn test -
Run the Application: You can run the
Mainclass directly from your IDE (IntelliJ/Eclipse) or use the command line. Upon execution, the program will:- Create a sample dataset in memory.
- Print the structure and total value to the console logs.
- Generate a file named
export_catalogo.txtin the project root.
- Data Persistence: Currently, data is stored in memory and lost when the application closes. Future implementation could include a Database connection.
- User Interface: The interaction is currently hardcoded in the Main class for demonstration purposes. A future update could add an interactive CLI menu or a GUI.
The following UML diagrams illustrate the structural design and the execution flow of the application.
This diagram details the Composite Pattern implementation. It shows how Product and Category implement the common interface CatalogItem, and how the CatalogFactory manages object creation.

This flowchart demonstrates the separation between the Data Preparation Phase (using Factory and Validation) and the Output Phase (using Iterator and Java I/O to generate the report).
