Skip to content

henrymegwai/Parcel-Management-System

Repository files navigation

Short Description

Design a system to automate the handling of incoming parcels at the package distribution center. This system must categorize parcels for processing by various departments according to their weight and value.

image image image

Features

Feature 1: Departmental Handling Based on Parcel Objects

The system should follow these current business rules for parcel distribution:

  • Parcels weighing up to 1 kg are directed to the "Mail" department.
  • Parcels weighing up to 10 kg are directed to the "Regular" department.
  • Parcels weighing over 10 kg are directed to the "Heavy" department.

Feature 2: High-Value Parcel Processing

Any parcel valued over €1,000 must receive approval from the "Insurance" department before processing by the relevant weight-based department.

Implementation:

Core Requirements

Requirement Status Implementation Details
Parse XML file (Container_68465468.xml) IMPLEMENTED Full XML parsing service with container/parcel/recipient/address mapping
Functional application IMPLEMENTED Complete .NET 8 Web API with Clean Architecture
Unit tests IMPLEMENTED Comprehensive xUnit tests with FluentAssertions
Presentation/Demo IMPLEMENTED Web API with Swagger UI and comprehensive testing guides

Feature 1: Departmental Handling Based on Weight

Requirement Status Implementation
Parcels ≤ 1kg → Mail department IMPLEMENTED Department { Name = "Mail", MinWeight = 0, MaxWeight = 1 }
Parcels ≤ 10kg → Regular department IMPLEMENTED Department { Name = "Regular", MinWeight = 1, MaxWeight = 10 }
Parcels > 10kg → Heavy department IMPLEMENTED Department { Name = "Heavy", MinWeight = 10, MaxWeight = decimal.MaxValue }

*** EXCEEDS REQUIREMENTS:**

  • Dynamic department management via API endpoints
  • Configurable weight ranges per department
  • Active/Inactive department status
  • Processing rule associations

Feature 2: High-Value Parcel Processing

Requirement Status Implementation
Parcels > €1,000 → Insurance approval IMPLEMENTED HighValueThreshold = 1000m in ProcessingRule
Insurance department integration IMPLEMENTED RequiresInsuranceApproval flag and processing notes

*** EXCEEDS REQUIREMENTS:**

  • Configurable threshold per processing rule
  • Detailed processing notes for insurance requirements
  • Multiple processing rules support

Feature 3: Software Productization (Optional)

Requirement Status Implementation
Customizable business rules IMPLEMENTED Full ProcessingRule and Department CRUD APIs
Different customer needs IMPLEMENTED Multiple processing rules with different thresholds

** Architecture & Technology Stack**

  • .NET 8 Web API (not console app as mentioned in README)
  • Clean Architecture with proper layer separation:
    • Parca.Domain/ - Domain entities and business logic
    • Parca.Application/ - Application services, DTOs, interfaces, validators
    • Parca.Infrastructure/ - Data access, external services
    • Parca.Api/ - Web API controllers
    • Parca.UnitTests/ - Unit tests
  • CQRS Pattern with MediatR for commands and queries
  • Entity Framework Core with SQLite database
  • Repository Pattern with Unit of Work
  • FluentValidation for input validation
  • Database Migrations with Entity Framework

Domain Model

  • Container entity with parcels collection
  • Parcel entity with weight, value, and recipient
  • Department entity with configurable weight ranges
  • ProcessingRule entity with high-value thresholds
  • ParcelProcessingResult entity for tracking processing outcomes
  • Recipient and Address entities for delivery information

** Infrastructure Services**

  • XmlParserService - Parses Container_68465468.xml format
  • ParcelProcessingService - Core business logic for parcel routing
  • Repository implementations for all entities
  • Database migrations with Entity Framework

API Endpoints

Container Processing

  • POST /api/parcelprocessing/process-container - Process container XML file

Department Management

  • GET /api/Department - Get all departments with summary
  • GET /api/Department/{id} - Get department by ID
  • GET /api/Department/byname/{name} - Get department by name
  • GET /api/Department/active - Get active departments only
  • GET /api/Department/byprocessingrule/{id} - Get departments by processing rule
  • POST /api/Department - Create new department
  • PUT /api/Department/{id} - Update department
  • DELETE /api/Department/{id} - Delete department
  • PATCH /api/Department/{id}/activate - Activate department
  • PATCH /api/Department/{id}/deactivate - Deactivate department

Processing Rule Management

  • GET /api/ProcessingRule - Get all processing rules
  • GET /api/ProcessingRule/{id} - Get processing rule by ID
  • GET /api/ProcessingRule/byname/{name} - Get processing rule by name
  • GET /api/ProcessingRule/active - Get active processing rules only
  • POST /api/ProcessingRule - Create new processing rule
  • PUT /api/ProcessingRule/{id} - Update processing rule
  • DELETE /api/ProcessingRule/{id} - Delete processing rule
  • PATCH /api/ProcessingRule/{id}/activate - Activate processing rule
  • PATCH /api/ProcessingRule/{id}/deactivate - Deactivate processing rule

Testing

  • Unit Tests: Comprehensive test coverage for:
  • Command and Query handlers
  • Service layer logic
  • Validation rules
  • XML parsing
  • Test Data Factory: Centralized test data creation (DepartmentTestDataFactory)
  • Integration Testing: API endpoint testing
  • Test Frameworks: xUnit with FluentAssertions and NSubstitute

Parca Management System - Frontend Application

  • Overview A modern Angular 17+ frontend application for the Parca Management System, providing a comprehensive web interface for managing departments, processing rules, parcel processing, and approval workflows.
  • Architecture & Technology Stack
  • Core Technologies
    • Angular 17+ - Modern standalone components architecture
    • TypeScript - Strict type safety and enhanced development experience
    • RxJS - Reactive programming for API calls and state management
    • SCSS - Advanced styling with variables and mixins
    • Angular Router - Client-side routing and navigation
  • Project Structure
Parca.App/
├──  README.md                      # Comprehensive documentation
├──  API_ENDPOINTS.md               # API reference guide
├──  setup.bat / setup.sh           # Setup scripts for Windows/Linux
├──  package.json                   # Enhanced with useful scripts
├── src/
│   ├──  styles.scss                # Global styling system
│   ├──  main.ts                    # Bootstrap with HTTP client
│   ├──  environments/              # Development & production configs
│   └── app/
│       ├──  app.component.ts       # Main app component
│       ├──  app.routes.ts          # Routing configuration
│       ├──  core/                   # Core services & models
│       │   ├── models/               # TypeScript interfaces
│       │   │   ├── department.model.ts
│       │   │   ├── processing-rule.model.ts
│       │   │   └── parcel-processing.model.ts
│       │   └── services/
│       │       └── api.service.ts    # Complete API integration
│       ├──  features/              # Feature modules
│       │   ├── home/                 # Dashboard/welcome page
│       │   ├── departments/          # Department management
│       │   ├── processing-rules/     # Processing rules management
│       │   └── parcel-processing/    # Parcel processing
│       └──  shared/
│           └── components/
│               └── navbar/           # Navigation component

Features Implemented

Department Management

  • View all departments with summary statistics
  • Create new departments with validation
  • Edit existing departments (modal-based)
  • Activate/deactivate departments
  • Delete departments with confirmation
  • Integration with processing rules

Processing Rules Management

  • View all processing rules with status
  • Create new processing rules
  • Edit existing rules (modal-based)
  • Activate/deactivate rules
  • Delete rules with confirmation
  • High-value threshold configuration

Parcel Processing

  • XML file upload with validation
  • Processing rule selection
  • Real-time processing status
  • Detailed results display
  • Error handling and user feedback

UI/UX Features

  • Responsive design
  • Loading states and spinners
  • Form validation
  • Error and success messages
  • Modal dialogs
  • Consistent styling system
  • Professional navigation

The application will be available at: http://localhost:4200

🔗 API Configuration

The app is pre-configured to connect to your Parca.Api:

  • Development: https://localhost:7142
  • Production: Update src/environments/environment.ts

Available Commands

npm start              # Development server
npm run build          # Production build  
npm run build:prod     # Production build (optimized)
npm test              # Run unit tests
npm run start:dev     # Development with dev config

Conclusion

  1. Production-ready enterprise application instead of a simple console app
  2. Full database persistence with Entity Framework migrations
  3. Comprehensive API for all business operations
  4. Dynamic configuration through database instead of static config files
  5. Professional architecture with Clean Architecture and CQRS patterns
  6. Extensive testing with proper test coverage
  7. Frontend Implementation with Angular
  8. Complete documentation for development and testing

** Adaptability Features**

The system is highly adaptable for:

  • Adding/removing departments through API
  • Configuring different weight ranges per department
  • Setting custom high-value thresholds per processing rule
  • Supporting multiple customer configurations
  • Enabling/disabling departments and processing rules

** Software Productization Readiness**

Despite not implementing the specific licensing features mentioned in the README, the system is well-suited for software productization through:

  • Multi-tenant support via processing rules
  • Dynamic configuration without code changes
  • Scalable architecture ready for enterprise deployment
  • Comprehensive API for integration with other systems

The implementation demonstrates a professional, enterprise-grade solution that goes far beyond the basic requirements, providing a solid foundation for a commercial parcel processing system.

About

An open source project for parcel management of a logistics startup company. Manages departments, processing rules, and parcel processing efficiently

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages