A comprehensive F# e-commerce simulation system with dual user interfaces (Console CLI + Modern GUI), SQLite database integration, advanced price calculation engine, and complete order management. This production-ready application demonstrates functional programming excellence with 17 automated tests and enterprise-level architecture.
- Project Overview
- Key Highlights
- Objectives
- Features
- User Interfaces
- Architecture
- Technology Stack
- Project Structure
- Getting Started
- Running the Application
- Database Information
- Team Roles & Responsibilities
- Development Guidelines
- Data Structures
- Core Modules
- Testing Strategy
- Export Capabilities
- Contributing
- Documentation
- License
The Simple Store Simulator is a production-ready F# e-commerce application that demonstrates advanced functional programming concepts. Built with clean architecture principles, the system features dual user interfaces (Console CLI and Avalonia GUI), SQLite database integration with 33+ products, comprehensive testing suite with 100% pass rate, and enterprise-grade features including order management, discount engine, and multi-format data export capabilities.
Development Period: Fall 2024 - Winter 2025
Version: 1.0 (Production Ready)
Target Framework: .NET 6.0
Total Tests: 17 Automated Unit Tests (All Passing)
- ✅ Dual User Interface: Professional Console CLI + Modern Avalonia Windows GUI
- ✅ Database Integration: SQLite with 33+ products across 6 categories
- ✅ Advanced Features: Tax calculation, shipping costs, multi-tier discount engine
- ✅ Data Export: JSON, CSV, and Text format support with timestamped orders
- ✅ Comprehensive Testing: 17 automated tests with 100% pass rate
- ✅ Functional Programming: Pure functions, immutable data, pattern matching
- ✅ Clean Architecture: Multi-tier layered design with clear separation of concerns
- ✅ Production Ready: Error handling, validation, and professional UX
- Master Functional Programming: Demonstrate F# syntax, immutability, and functional paradigms
- Build Real-World Systems: Create production-grade e-commerce application
- Database Operations: Integrate SQLite for persistent product catalog
- UI Development: Implement both CLI and GUI interfaces
- Advanced Calculations: Tax, shipping, discounts, and price calculations
- Testing Excellence: Achieve comprehensive test coverage
- Team Collaboration: Practice role-based agile development
- Best Practices: Apply clean code, SOLID principles, and documentation standards
-
Product Catalog Management
- 33+ products across 6 categories (Snacks, Dairy, Beverages, Sweets, Fruits, Vegetables)
- SQLite database integration with persistent storage
- Real-time stock tracking and validation
- Product attributes: ID, Name, Price (EGP), Description, Category, Stock
- Categories: Snacks, Dairy, Beverages, Sweets, Fruits, Vegetables, Frozen
-
Shopping Cart Operations
- Add products with quantity selection and stock validation
- Remove products from cart
- Update product quantities dynamically
- View cart contents with line items
- Automatic total calculation
- Cart persistence across sessions
- Immutable list-based implementation
-
Advanced Price Calculation Engine
- Subtotal calculation per line item (price × quantity)
- Cart subtotal aggregation
- Tax Calculation: 14% VAT (configurable)
- Shipping Costs: Free shipping over 200 EGP, otherwise 30 EGP
- Multi-Tier Discount System:
- Percentage-based discounts (e.g., 10% off)
- Fixed amount discounts (e.g., 50 EGP off)
- Buy X Get Y Free (e.g., Buy 3 Get 1 Free)
- Minimum purchase requirements
- Final total with all adjustments
-
Search & Filter System
- Search by Name: Case-insensitive product search
- Filter by Price Range: Min/max price filtering
- Filter by Category: Browse by product category
- Sort Products: By price (ascending/descending) or name
- Combined Filters: Apply multiple criteria simultaneously
- Category Listing: View all available categories
-
Order Management & Persistence
- Generate unique order IDs (GUID-based)
- Timestamped order creation (YYYYMMDD_HHMMSS)
- Complete order summaries with all details
- Save orders to JSON files in
data/orders/directory - Order history tracking
- Automatic file naming with order ID and timestamp
-
Multi-Format Data Export
- JSON Export: Structured data with full order details
- CSV Export: Spreadsheet-compatible format
- Text Export: Human-readable receipt format
- Customizable export paths
- Error handling and validation
- 🎨 Colored output (success, error, warning, info)
- 📦 Box-drawing ASCII art menus
- 🔢 Interactive numeric menu selection
- 💬 Input validation and error messaging
- 📊 Formatted tables and summaries
- 🎯 Clear navigation and workflow
- ⚡ Fast keyboard-driven interaction
- 🖥️ Modern desktop application
- 🎨 Professional UI with Fluent design
- 📋 Product grid with search and filters
- 🛒 Real-time shopping cart panel
- 🔍 Instant search functionality
- 📂 Category dropdown filtering
- 🛡️ Stock status indicators
- ✅ Add to cart buttons with validation
- 🗑️ Remove from cart functionality
- 💳 Checkout with order confirmation
- 📱 Responsive layout (resizable windows)
- 🎯 MVVM architecture pattern
The Simple Store Simulator features TWO professional user interfaces to suit different user preferences:
Location: GUI/ folder
Features:
- ✨ Modern desktop application with Fluent design
- 🎨 Professional Windows interface
- 📋 Product Grid: Scrollable list with all product details
- 🛒 Shopping Cart Panel: Real-time cart updates
- 🔍 Search Bar: Instant product search as you type
- 📂 Category Dropdown: Quick filtering by category
- ➕ Add to Cart Buttons: One-click product addition
- 🗑️ Remove Buttons: Easy cart item removal
- 💳 Checkout Button: Complete order processing
- 📊 Total Display: Real-time price calculation
- 🛡️ Stock Indicators: Visual out-of-stock warnings
- 📱 Responsive Design: Resizable window with adaptive layout
How to Run:
cd GUI
dotnet runUI Components:
-
Header Bar (Dark Blue Background)
- Store title: "🛒 Simple Store Simulator"
- Cart item count badge
-
Toolbar (Light Gray Background)
- Search textbox with placeholder "Search products..."
- Search button
- Category dropdown (All Categories, Snacks, Dairy, etc.)
- Show All button
-
Main Content (Split View)
- Left Panel (60%): Product catalog
- Product cards with name, price, description
- Category and stock information
- "Add to Cart" button (green, disabled if out of stock)
- Right Panel (40%): Shopping cart
- Cart items with quantity and price
- Remove buttons for each item
- Subtotal, Tax, Shipping, Discount, Total
- Checkout button
- Left Panel (60%): Product catalog
Technology Stack:
- UI Framework: Avalonia 11.3.9 (cross-platform .NET UI)
- Architecture: MVVM (Model-View-ViewModel)
- Data Binding: Two-way binding with INotifyPropertyChanged
- Navigation: ViewLocator pattern
Project File: GUI/SimpleStoreSimulator.GUI.fsproj
┌─────────────────────────────────────────────────────┐
│ Presentation Layer │
│ (UI Module - Forms/Console) │
└──────────────────────┬──────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────┐
│ Application Layer │
│ (Business Logic & Workflow Orchestration) │
│ ┌──────────────┐ ┌──────────────┐ ┌───────────┐ │
│ │ Catalog │ │ Cart │ │ Checkout │ │
│ │ Service │ │ Service │ │ Service │ │
│ └──────────────┘ └──────────────┘ └───────────┘ │
└──────────────────────┬──────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────┐
│ Domain Layer │
│ (Core Business Logic) │
│ ┌──────────────┐ ┌──────────────┐ ┌───────────┐ │
│ │ Product │ │ CartItem │ │ Order │ │
│ │ Types │ │ Types │ │ Types │ │
│ └──────────────┘ └──────────────┘ └───────────┘ │
└──────────────────────┬──────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────┐
│ Data Access Layer │
│ (JSON Persistence & File I/O) │
└─────────────────────────────────────────────────────┘
UI Module
├── Catalog Module
├── Cart Module
├── Search Module
└── Checkout Module
└── Calculator Module
└── FileIO Module
User Input → UI Layer → Service Layer → Domain Logic → Data Layer
↓
User Output ← UI Layer ← Service Layer ← Pure Functions
- Language: F# (Functional-first .NET language)
- Framework: .NET 6.0
- Build Tool: .NET CLI / MSBuild
- Version Control: Git + GitHub
- Database: SQLite 8.0.0 (Microsoft.Data.Sqlite)
- Data Format: JSON (System.Text.Json + FSharp.SystemTextJson 1.3.13)
- Products: 33+ items in SQLite database
- Test Framework: Expecto 10.2.1 (F# testing framework)
- Test SDK: YoloDev.Expecto.TestSdk 0.14.2
- Test Runner: Microsoft.NET.Test.Sdk 17.8.0
- Coverage: 30 automated unit tests (100% pass rate)
- UI Framework: Avalonia 11.3.9 (cross-platform .NET UI)
- Desktop Support: Avalonia.Desktop 11.3.9
- Theme: Avalonia.Themes.Fluent 11.3.9
- Fonts: Avalonia.Fonts.Inter 11.3.9
- Diagnostics: Avalonia.Diagnostics 11.3.9 (Debug only)
- MVVM: CommunityToolkit.Mvvm 8.2.1
<!-- Core Library -->
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.0" />
<PackageReference Include="FSharp.SystemTextJson" Version="1.3.13" />
<!-- Testing -->
<PackageReference Include="Expecto" Version="10.2.1" />
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.14.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<!-- GUI Application -->
<PackageReference Include="Avalonia" Version="11.3.9" />
<PackageReference Include="Avalonia.Desktop" Version="11.3.9" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.9" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />- IDEs: Visual Studio 2022, VS Code (with Ionide), JetBrains Rider
- Extensions: Ionide-fsharp (VS Code F# support)
- Terminal: PowerShell, CMD, Windows Terminal
Simple Store Simulator/
├── 📄 SimpleStoreSimulator.fsproj # Main library project file
├── 📄 README.md # This comprehensive guide
├── 📄 .gitignore # Git ignore rules
│
├── 📂 src/ # Source code (Core Business Logic)
│ ├── 📄 Program.fs # Console UI entry point
│ │
│ ├── 📂 Product/ # Product Module
│ │ ├── Product.fs # Product types and catalog operations
│ │ └── ProductDatabase.fs # SQLite database integration (33+ products)
│ │
│ ├── 📂 Cart/ # Shopping Cart Module
│ │ ├── CartTypes.fs # Cart and CartItem type definitions
│ │ ├── CartConfig.fs # Cart configuration (tax, shipping)
│ │ └── CartOperations.fs # Cart add/remove/update operations
│ │
│ ├── 📂 Calculator/ # Price Calculation Module
│ │ ├── PriceCalculator.fs # Subtotal, tax, shipping, total calculations
│ │ └── DiscountEngine.fs # Multi-tier discount system
│ │
│ ├── 📂 Search/ # Search & Filter Module
│ │ ├── SearchTypes.fs # Search criteria types
│ │ └── SearchOperations.fs # Search, filter, sort functions
│ │
│ └── 📂 FileIO/ # Data Persistence Module
│ ├── JsonSerializer.fs # JSON serialization/deserialization
│ └── FileOperations.fs # File I/O, CSV, text export
│
├── 📂 GUI/ # Windows GUI Application (Avalonia)
│ ├── 📄 SimpleStoreSimulator.GUI.fsproj # GUI project file
│ ├── 📄 Program.fs # GUI entry point
│ ├── 📄 App.axaml # Application XAML
│ ├── 📄 App.axaml.fs # Application code-behind
│ ├── 📄 ViewLocator.fs # MVVM view location
│ ├── 📄 Converters.fs # Value converters for data binding
│ ├── 📄 app.manifest # Windows application manifest
│ ├── 📄 README-GUI.md # GUI-specific documentation
│ │
│ ├── 📂 ViewModels/ # MVVM ViewModels
│ │ ├── ViewModelBase.fs # Base ViewModel class
│ │ └── MainWindowViewModel.fs # Main window ViewModel
│ │
│ ├── 📂 Views/ # MVVM Views
│ │ ├── MainWindow.axaml # Main window XAML
│ │ └── MainWindow.axaml.fs # Main window code-behind
│ │
│ ├── 📂 Assets/ # GUI assets (icons, images)
│ ├── 📂 bin/ # Build output
│ ├── 📂 obj/ # Build intermediate files
│ │
│ └── 📂 data/ # GUI-specific data
│ └── 📂 orders/ # Saved orders from GUI
│ ├── order_*.json # Individual order files
│ └── ... # (100+ order files)
│
├── 📂 tests/ # Automated Testing Suite
│ ├── 📄 SimpleStoreSimulator.Tests.fsproj # Test project file
│ ├── 📄 Main.fs # Test runner entry point
│ ├── 📄 README.md # Testing documentation
│ │
│ ├── 📄 ProductTests.fs # Product module tests (3 tests)
│ ├── 📄 CartOperationsTests.fs # Cart operations tests (4 tests)
│ ├── 📄 PriceCalculatorTests.fs # Price calculator tests (3 tests)
│ ├── 📄 SearchOperationsTests.fs # Search & filter tests (3 tests)
│ ├── 📄 JsonAndDatabaseTests.fs # JSON & DB tests (1 test)
│ ├── 📄 FileOperationsAutomationTests.fs # File I/O tests (1 test)
│ └── 📄 DiscountEngineAutomationTests.fs # Discount tests (2 tests)
│
│ └── 📂 bin/, obj/ # Test build outputs
│
├── 📂 docs/ # Documentation
│ ├── 📄 PROJECT_DOCUMENTATION.md # Comprehensive project docs (745 lines)
│ ├── 📄 ARCHITECTURE.md # Detailed architecture guide
│ ├── 📄 System Architecture.drawio # Architecture diagrams
│ └── 📄 Untitled Diagram.drawio # Additional diagrams
│
├── 📂 bin/ # Build output directory
│ └── Debug/
│ ├── net6.0/ # .NET 6.0 build
│ └── net8.0/ # .NET 8.0 build (if applicable)
│
└── 📂 obj/ # Build intermediate files
├── project.assets.json
├── *.nuget.dgspec.json
├── *.nuget.g.props
├── *.nuget.g.targets
└── Debug/
src/: Core business logic organized by domain (Product, Cart, Calculator, Search, FileIO)GUI/: Complete Avalonia GUI application with MVVM architecturetests/: 17 essential unit tests with 100% pass ratedocs/: Complete project documentation and architecture diagramsGUI/data/orders/: Persistent storage for customer orders (100+ saved orders)
SearchTypes.fs → Product.fs → ProductDatabase.fs → SearchOperations.fs
→ CartTypes.fs → CartConfig.fs → PriceCalculator.fs → DiscountEngine.fs
→ JsonSerializer.fs → FileOperations.fs → CartOperations.fs
- .NET SDK 6.0+: Download from https://dotnet.microsoft.com/download
- F# Language Support: Included with .NET SDK
- Git: For version control (https://git-scm.com/)
- IDE (Choose one):
- Visual Studio 2022 (with F# support)
- Visual Studio Code (with Ionide-fsharp extension)
- JetBrains Rider
-
Clone the repository
git clone https://github.com/Omar-Mega-Byte/Simple-Store-Simulator.git cd "Simple-Store-Simulator"
-
Restore NuGet packages
dotnet restore
-
Build the solution
dotnet build
-
Run tests (verify everything works)
cd tests dotnet test
Expected output: ✅ All 17 tests passed
Run the console-based interface:
# From project root
dotnet run --project SimpleStoreSimulator.fsproj
# Or directly from src folder
cd src
dotnet runRun the Avalonia desktop application:
# Navigate to GUI folder
cd GUI
dotnet run
# Or from project root
dotnet run --project GUI/SimpleStoreSimulator.GUI.fsproj# Run all tests
cd tests
dotnet test
# Run with detailed output
dotnet test --logger "console;verbosity=detailed"
# Run specific test file
dotnet test --filter "FullyQualifiedName~ProductTests"# Build optimized release version
dotnet build -c Release
# Publish self-contained executable (Windows)
dotnet publish -c Release -r win-x64 --self-contained
# GUI Application release build
cd GUI
dotnet publish -c Release -r win-x64 --self-contained- Location: In-memory database (ProductDatabase.fs)
- Products: 33+ items across 6 categories
- Schema:
CREATE TABLE Products ( Id INTEGER PRIMARY KEY, Name TEXT NOT NULL, Price REAL NOT NULL, Description TEXT, Category TEXT, Stock INTEGER DEFAULT 0 )
- Snacks (8 products): Chips, Popcorn, Crackers, Nuts, Pretzels, Cookies, Energy Bars
- Dairy (5 products): Milk, Cheese, Yogurt, Butter, Cream
- Beverages (7 products): Water, Juice, Soda, Coffee, Tea, Energy Drinks
- Sweets (6 products): Chocolate, Candy, Gummies, Mints
- Fruits (4 products): Apples, Bananas, Oranges, Grapes
- Vegetables (3 products): Tomatoes, Lettuce, Carrots
| ID | Name | Price (EGP) | Category | Stock |
|---|---|---|---|---|
| 1 | Chips | 15.00 | Snacks | 50 |
| 2 | Milk | 25.00 | Dairy | 30 |
| 3 | Water | 5.00 | Beverages | 100 |
| 4 | Chocolate | 20.00 | Sweets | 40 |
| 5 | Apples | 30.00 | Fruits | 25 |
See src/Product/ProductDatabase.fs for complete product list
Responsibilities:
- Design and implement the
Producttype - Initialize product catalog using Map data structure
- Create functions to retrieve and display products
- Implement product catalog structure
Key Deliverables:
Domain/Types.fs- Product type definitionCatalog/CatalogOperations.fs- Catalog functionsCatalog/ProductData.fs- Sample product data
Skills Focus:
- F# record types
- Map data structure
- Immutable collections
Responsibilities:
- Implement shopping cart operations
- Add products to cart with immutable list operations
- Remove products from cart
- Update product quantities
- Maintain cart state immutably
Key Deliverables:
Cart/CartTypes.fs- Cart and CartItem typesCart/CartOperations.fs- Cart manipulation functions
Skills Focus:
- List operations
- Pattern matching
- Immutable state management
- Pure functions
Responsibilities:
- Implement price calculation functions
- Calculate subtotals for cart items
- Compute total cart value
- Apply discounts (if applicable)
- Implement tax calculations (optional)
Key Deliverables:
Calculator/PriceCalculator.fs- Calculation functionsCalculator/DiscountEngine.fs- Discount logic
Skills Focus:
- Mathematical operations in F#
- Function composition
- Option types for discounts
Responsibilities:
- Implement product search functionality
- Create filter functions (by price, category, etc.)
- Implement sorting operations
- Build query composition functions
Key Deliverables:
Search/SearchTypes.fs- Search criteria typesSearch/SearchOperations.fs- Search and filter functions
Skills Focus:
- List filtering and mapping
- Higher-order functions
- Query expressions
- Function pipelines
Responsibilities:
- Implement JSON serialization
- Save cart summary to file
- Load product catalog from JSON
- Handle file I/O operations
- Manage data persistence
Key Deliverables:
FileIO/JsonSerializer.fs- JSON operationsFileIO/FileOperations.fs- File system functionsdata/products.json- Product data file
Skills Focus:
- JSON serialization/deserialization
- File I/O
- Error handling
- Side effects management
Responsibilities:
- Design and implement user interface
- Create menu system
- Display product catalog
- Show cart contents
- Format output displays
- Handle user input
Key Deliverables:
UI/ConsoleUI.fs- Main UI logicUI/Menu.fs- Menu systemUI/DisplayHelpers.fs- Formatting functions
Skills Focus:
- Console I/O
- String formatting
- User interaction flows
- Integration of all modules
Responsibilities:
- Write unit tests for all modules
- Ensure cart operations correctness
- Test edge cases
- Validate calculation accuracy
- Integration testing
- Create test data
Key Deliverables:
- All files in
tests/directory - Test documentation
- Bug reports and fixes
Skills Focus:
- Unit testing in F#
- Test frameworks (Expecto, FsUnit)
- Test-driven development
- Quality assurance
Documentation Lead - كيرلس ساري عيد رومان
Responsibilities:
- Maintain comprehensive documentation
- Create technical documentation files
- Document APIs and module interfaces
- Write team collaboration guidelines
Key Deliverables:
- README.md updates
- ARCHITECTURE.md
- API.md
- TEAM_GUIDE.md
Skills Focus:
- Technical writing
- Documentation standards
- Markdown formatting
Version Control Lead - عمر أحمد الرفاعي طليس
Responsibilities:
- Manage GitHub repository
- Review and merge pull requests
- Create and assign issues
- Track project progress
- Facilitate team collaboration
Key Deliverables:
- GitHub Issues and Projects setup
- PR review and merge management
- Branch management
- Repository organization
Skills Focus:
- Git workflows
- GitHub collaboration
- Project management
- Team coordination
-
Naming Conventions
- Use PascalCase for types and modules:
Product,CartOperations - Use camelCase for functions and values:
addToCart,calculateTotal - Use descriptive names:
productIdinstead ofid
- Use PascalCase for types and modules:
-
Function Design
- Keep functions pure (no side effects) whenever possible
- Use pattern matching instead of if-else chains
- Prefer function composition and pipelines
- Keep functions small and focused (single responsibility)
-
Immutability
- Never mutate data structures
- Return new instances when state changes
- Use immutable collections (List, Map, Set)
-
Type Safety
- Define custom types for domain concepts
- Use discriminated unions for state representation
- Avoid primitive obsession
-
Error Handling
- Use
Optiontype for values that might not exist - Use
Resulttype for operations that can fail - Provide meaningful error messages
- Use
- Create feature branch from
main - Make commits with descriptive messages
- Push branch and create pull request
- Request review from team members
- Merge after approval
<type>: <subject>
<body>
<footer>
Types: feat, fix, docs, style, refactor, test, chore
Example:
feat: add product search by name
Implemented search function that filters products by name
using case-insensitive matching.
Closes #15
type Product = {
Id: int
Name: string
Price: decimal
Description: string
Category: string
Stock: int
}type CartItem = {
Product: Product
Quantity: int
}type ShoppingCart = {
Items: CartItem list
CreatedAt: DateTime
}type CartConfig = {
TaxRate: decimal // 14% VAT
FreeShippingThreshold: decimal // 200 EGP
ShippingCost: decimal // 30 EGP
}type OrderSummary = {
OrderId: string // GUID
Items: CartItem list
Subtotal: decimal
Tax: decimal
Shipping: decimal
Discount: decimal
Total: decimal
OrderDate: DateTime
}type DiscountType =
| Percentage of float // e.g., 10% off
| FixedAmount of decimal // e.g., 50 EGP off
| BuyXGetYFree of int * int // e.g., Buy 3 Get 1 Free
type Discount = {
Name: string
Type: DiscountType
MinimumPurchase: decimal option
}type SearchCriteria = {
Name: string option
MinPrice: decimal option
MaxPrice: decimal option
Category: string option
}
type SortOption =
| PriceAscending
| PriceDescending
| NameAscending
| NameDescendingAll data structures in this project follow functional programming principles:
- ✅ Immutability: All types are immutable records
- ✅ Pure Functions: Functions never mutate input parameters
- ✅ Type Safety: Strong typing prevents runtime errors
- ✅ Pattern Matching: Discriminated unions for state representation
- ✅ Option Types: Explicit handling of nullable values
- ✅ Result Types: Functional error handling
Files:
Product.fs- Product types and catalog operationsProductDatabase.fs- SQLite integration with 33+ products
Purpose:
- Define Product type and catalog structure
- Initialize product database from SQLite
- Manage product inventory and stock levels
Key Functions:
// Database operations
loadProductsFromDatabase: unit -> Product list
insertProduct: SqliteConnection -> Product -> unit
updateProductStock: SqliteConnection -> int -> int -> unit
// Catalog operations
initializeCatalog: unit -> ProductCatalog
getProduct: ProductCatalog -> int -> Product option
getAllProducts: ProductCatalog -> Product list
getProductsByCategory: ProductCatalog -> string -> Product list
isInStock: Product -> int -> bool
updateStock: ProductCatalog -> int -> int -> ProductCatalog
formatPrice: decimal -> string
displayProduct: Product -> unit
displayCatalog: string -> ProductCatalog -> unitProduct Categories:
- Snacks, Dairy, Beverages, Sweets, Fruits, Vegetables, Frozen
Files:
CartTypes.fs- Cart and CartItem type definitionsCartConfig.fs- Configuration (tax rate, shipping)CartOperations.fs- Cart manipulation functions
Purpose:
- Manage shopping cart state immutably
- Handle add/remove/update operations
- Validate stock availability
Key Functions:
// Cart creation and queries
createCart: unit -> ShoppingCart
getCartItemCount: ShoppingCart -> int
isEmpty: ShoppingCart -> bool
findCartItem: Product -> ShoppingCart -> CartItem option
// Cart modifications
addToCart: Product -> int -> ShoppingCart -> ShoppingCart
removeFromCart: Product -> ShoppingCart -> ShoppingCart
updateQuantity: Product -> int -> ShoppingCart -> ShoppingCart
clearCart: ShoppingCart -> ShoppingCart
// Display and reporting
displayCart: ShoppingCart -> unit
getCartSummary: ShoppingCart -> stringConfiguration:
- Tax Rate: 14% (VAT)
- Free Shipping Threshold: 200 EGP
- Standard Shipping Cost: 30 EGP
Files:
PriceCalculator.fs- Price and total calculationsDiscountEngine.fs- Multi-tier discount system
Purpose:
- Calculate subtotals, tax, shipping, and totals
- Apply various discount types
- Generate order summaries
Key Functions:
// Price calculations
calculateItemSubtotal: CartItem -> decimal
calculateSubtotal: ShoppingCart -> decimal
calculateTax: decimal -> decimal -> decimal
calculateShipping: decimal -> CartConfig -> decimal
calculateTotal: ShoppingCart -> CartConfig -> decimal
// Order processing
createOrderSummary: ShoppingCart -> CartConfig -> OrderSummary
displayOrderSummary: OrderSummary -> unit
// Discount engine
applyPercentageDiscount: decimal -> float -> decimal
applyFixedDiscount: decimal -> decimal -> decimal
applyBuyXGetYFree: CartItem -> int -> int -> decimal
calculateDiscount: CartItem list -> Discount -> decimalDiscount Types:
- Percentage (e.g., 10% off)
- Fixed Amount (e.g., 50 EGP off)
- Buy X Get Y Free (e.g., Buy 3 Get 1 Free)
Files:
SearchTypes.fs- Search criteria and sort optionsSearchOperations.fs- Search, filter, and sort functions
Purpose:
- Enable product discovery and filtering
- Sort products by various criteria
- Combine multiple search filters
Key Functions:
// Search and filter
searchByName: Product list -> string -> Product list
filterByPriceRange: Product list -> decimal -> decimal -> Product list
filterByCategory: Product list -> string -> Product list
applyCriteria: Product list -> SearchCriteria -> Product list
// Sorting
sortProducts: Product list -> SortOption -> Product list
sortByPriceAsc: Product list -> Product list
sortByPriceDesc: Product list -> Product list
sortByName: Product list -> Product list
// Utilities
getCategories: Product list -> string list
displaySearchResults: Product list -> unitSearch Capabilities:
- Case-insensitive name search
- Price range filtering
- Category filtering
- Multiple sort options
- Combined criteria
Files:
JsonSerializer.fs- JSON serialization/deserializationFileOperations.fs- File I/O and export functions
Purpose:
- Persist order data in JSON format
- Export data to multiple formats (JSON, CSV, Text)
- Handle file system operations with error handling
Key Functions:
// JSON operations
serializeToJson<'T>: 'T -> string
deserializeFromJson<'T>: string -> 'T option
saveToJsonFile<'T>: string -> 'T -> Result<unit, string>
loadFromJsonFile<'T>: string -> Result<'T, string>
// Order persistence
saveOrder: OrderSummary -> string -> Result<unit, string>
loadOrder: string -> Result<OrderSummary, string>
generateOrderFileName: string -> string
// Export formats
exportToCsv: CartItem list -> string -> Result<unit, string>
exportToText: OrderSummary -> string -> Result<unit, string>
ensureDirectoryExists: string -> unitFile Formats:
- JSON: Structured order data with full details
- CSV: Spreadsheet-compatible format for cart items
- Text: Human-readable receipt format
Storage Location:
- Console orders:
data/orders/ - GUI orders:
GUI/data/orders/
Purpose:
- Provide interactive console user interface
- Display menus and handle user input
- Coordinate all modules for complete workflow
Features:
- Colored console output (success/error/warning/info)
- ASCII box-drawing for visual appeal
- Input validation and error handling
- Menu-driven navigation
- Interactive prompts
Main Menu Options:
- View All Products
- Search Products
- Browse by Category
- Filter by Price Range
- View Cart
- Shopping Cart Management
- Checkout
- Product Statistics
- Best Deals
- Exit
Architecture: MVVM (Model-View-ViewModel)
Components:
- ViewModels: Business logic and state management
ViewModelBase.fs- Base class for ViewModelsMainWindowViewModel.fs- Main window logic
- Views: XAML-based UI
MainWindow.axaml- Main window layoutMainWindow.axaml.fs- Code-behind
- Converters: Data binding converters
Converters.fs- Value converters
- App: Application entry
App.axaml- App resources and stylingProgram.fs- Entry point
Features:
- Product grid with search
- Shopping cart panel
- Real-time updates
- Category filtering
- Stock validation
- Checkout workflow
Total Tests: 17 automated unit tests
Pass Rate: 100% ✅
Framework: Expecto 10.2.1
Location: tests/ directory
- ✅ Catalog initialization from database
- ✅ Get product by ID with correct data
- ✅ Update stock changes correctly
- ✅ Add item to empty cart
- ✅ Add same item twice (quantity accumulation)
- ✅ Remove product from cart
- ✅ Checkout updates catalog stock
- ✅ Calculate cart subtotal with multiple items
- ✅ Calculate tax from subtotal
- ✅ Calculate cart total with all fees
- ✅ Search by name finds matching products
- ✅ Filter by category returns only matching
- ✅ Apply search criteria filters correctly
- ✅ Database initializes successfully
- ✅ Save order creates JSON file successfully
- ✅ Apply percentage discount to cart
- ✅ Buy X Get Y discount calculation
# Run all tests
cd tests
dotnet test
# Run with detailed output
dotnet test --logger "console;verbosity=detailed"
# Run specific test suite
dotnet test --filter "FullyQualifiedName~CartOperationsTests"
# Run tests with coverage (if coverage tool installed)
dotnet test /p:CollectCoverage=truePassed! - Failed: 0, Passed: 17, Skipped: 0, Total: 17, Duration: 507 ms
[16:32:47 INF] EXPECTO? Running tests...
[16:32:47 INF] EXPECTO! 17 tests run - 17 passed, 0 failed, 0 errored, 0 ignored
- ✅ Unit Testing: Test each function in isolation
- ✅ Edge Cases: Test boundary conditions and edge cases
- ✅ Error Handling: Verify error conditions are handled properly
- ✅ Pure Functions: Leverage F# pure functions for predictable tests
- ✅ Test Data: Use realistic test data matching production scenarios
- ✅ Continuous Testing: Run tests before every commit
- ✅ Regression Testing: Ensure new features don't break existing functionality
- ✅ Achieved: Essential business logic tested
- ✅ Achieved: Critical cart operations covered
- ✅ Achieved: Core calculation functions verified
- ✅ Achieved: Key search and filter operations tested
- ✅ Achieved: Database and file I/O operations validated
- No Warnings: Clean compilation with zero warnings
- No Errors: All tests pass consistently
- Code Reviews: Peer-reviewed by team members
- Functional Correctness: Business rules validated through tests
The system supports multiple export formats for order data:
Format: Structured JSON with complete order details
Example Output:
{
"OrderId": "6efb04ad-758c-426a-ad16-2c9bc7a9e305",
"Items": [
{
"Product": {
"Id": 1,
"Name": "Chips",
"Price": 15.00,
"Description": "Crispy potato chips",
"Category": "Snacks",
"Stock": 50
},
"Quantity": 2
}
],
"Subtotal": 30.00,
"Tax": 4.20,
"Shipping": 30.00,
"Discount": 0.00,
"Total": 64.20,
"OrderDate": "2025-12-13T12:33:09"
}File Location: GUI/data/orders/order_{GUID}_{TIMESTAMP}.json
Format: Comma-separated values for spreadsheet import
Example Output:
ProductId,ProductName,Quantity,Price,Subtotal
1,Chips,2,15.00,30.00
4,Chocolate,1,20.00,20.00Use Cases:
- Import into Excel/Google Sheets
- Data analysis
- Inventory reporting
Format: Human-readable receipt
Example Output:
========================================
ORDER RECEIPT
========================================
Order ID: 6efb04ad-758c-426a-ad16-2c9bc7a9e305
Date: 2025-12-13 12:33:09
----------------------------------------
ITEMS:
----------------------------------------
Chips x2 30.00 EGP
Chocolate x1 20.00 EGP
----------------------------------------
Subtotal: 50.00 EGP
Tax (14%): 7.00 EGP
Shipping: 30.00 EGP
Discount: 0.00 EGP
----------------------------------------
TOTAL: 87.00 EGP
========================================
// Save order to JSON
saveOrder: OrderSummary -> string -> Result<unit, string>
// Export cart items to CSV
exportToCsv: CartItem list -> string -> Result<unit, string>
// Export order summary to text receipt
exportToText: OrderSummary -> string -> Result<unit, string>The application maintains a persistent history of all orders:
- Location:
GUI/data/orders/ - Count: 100+ saved orders
- Format:
order_{GUID}_{YYYYMMDD_HHMMSS}.json - Retention: Permanent (until manually deleted)
-
Choose a Task
- Check GitHub Issues for assigned tasks
- Coordinate with team members
-
Create Branch
git checkout -b feature/your-feature-name
-
Implement & Test
- Write code following guidelines
- Add unit tests
- Test locally
-
Commit Changes
git add . git commit -m "feat: description of changes"
-
Push & Create PR
git push origin feature/your-feature-name
-
Code Review
- Address review comments
- Update as needed
-
Merge
- After approval, merge to main branch
- Code follows F# style guidelines
- Functions are pure and immutable
- Unit tests are included
- Documentation is updated
- No compiler warnings
- Builds successfully
Comprehensive documentation is available in the docs/ directory:
-
README.md (This file)
- Complete project overview
- Installation and setup guide
- Feature descriptions
- Team roles and responsibilities
- Development guidelines
-
docs/PROJECT_DOCUMENTATION.md (745 lines)
- Executive summary
- Detailed functional requirements
- System architecture
- Technical implementation details
- Database design
- Usage guide
- Complete API reference
-
docs/ARCHITECTURE.md
- Detailed architecture diagrams
- Module dependencies
- Data flow documentation
- Design patterns used
-
GUI/README-GUI.md (337 lines)
- GUI-specific documentation
- Avalonia UI guide
- MVVM architecture explanation
- UI component descriptions
- Screenshots and examples
-
tests/README.md
- Testing strategy
- Test suite documentation
- How to write tests
- Test execution guide
docs/System Architecture.drawio- System architecture diagramdocs/Untitled Diagram.drawio- Additional diagrams
- Repository: https://github.com/Omar-Mega-Byte/Simple-Store-Simulator
- Issues: GitHub Issues
- Project Lead: omar.tolis2004@gmail.com
- عمر أحمد الرفاعي طليس - Team Leader & Search/Filter Developer & Tester
- عمر أحمد محمد أحمد - Price Calculator Developer
- عمر أحمد محمود عواد - Catalog Developer
- جمال الدين أيمن عبد الرحمن - Tester
- مايكل عماد عدلي - File Save/Load Developer
- باسل وليد حامد محمد - Cart Logic Developer
- علي محمد جمعة زكي - UI Developer
- كيرلس ساري عيد رومان - Documentation Lead
This project is developed for educational purposes as part of the Programming Languages - 3 course.
Academic Information:
- Course: Programming Languages - 3
- Academic Year: 2024-2025
- Term: First Term (Fall 2024 - Winter 2025)
- Institution: Faculty of Computers and Artificial Intelligence
- Repository: https://github.com/Omar-Mega-Byte/Simple-Store-Simulator
- F# for Fun and Profit - Comprehensive F# guide
- F# Documentation - Official Microsoft docs
- F# Cheat Sheet - Quick reference
- ✅ Immutability - All data structures are immutable
- ✅ Pure Functions - Side-effect-free functions
- ✅ Pattern Matching - Elegant control flow
- ✅ Higher-Order Functions - Functions as parameters
- ✅ Function Composition - Pipe operators and composition
- ✅ Discriminated Unions - Type-safe state representation
- ✅ Option Types - Explicit nullable handling
- ✅ Result Types - Functional error handling
- ✅ Record Types - Immutable data structures
- ✅ List Operations - Functional list processing
- Ionide - F# extension for VS Code
- Expecto - F# testing framework
- Avalonia - Cross-platform .NET UI framework
- SQLite - Lightweight database engine
- System.Text.Json - JSON library
- ✅ Complete Implementation: All planned features delivered
- ✅ Dual Interfaces: CLI + GUI both fully functional
- ✅ 100% Test Pass Rate: All 17 automated tests passing
- ✅ Production Ready: Error handling, validation, professional UX
- ✅ Database Integration: SQLite with 33+ products
- ✅ Advanced Features: Tax, shipping, multi-tier discounts
- ✅ Data Persistence: 100+ saved orders with multi-format export
- ✅ Clean Architecture: Well-organized, maintainable codebase
- ✅ Comprehensive Documentation: 2000+ lines of documentation
- ✅ Team Collaboration: Successful role-based development
Built with 💖 using F# - Functional Programming for Real-World Applications
Developed by Team:
- عمر أحمد الرفاعي طليس (Team Leader)
- عمر أحمد محمد أحمد
- عمر أحمد محمود عواد
- جمال الدين أيمن عبد الرحمن
- مايكل عماد عدلي
- باسل وليد حامد محمد
- علي محمد جمعة زكي
- كيرلس ساري عيد رومان
© 2024-2025 | Simple Store Simulator Team