SME Store System

A complete modular application demonstrating real-world architecture.

Project Structure

testcase/
├── main.unna           # Entry point
├── models/
│   ├── product.unna    # Product struct & operations
│   ├── customer.unna   # Customer struct & tiers
│   └── order.unna      # Order struct & processing
├── services/
│   ├── inventory.unna  # Stock management
│   ├── sales.unna      # Sales processing
│   └── reporting.unna  # Report generation
└── utils/
    ├── logger.unna     # Logging utility
    └── validator.unna  # Validation helpers

Running the Demo

./bin/unnarize examples/testcase/main.unna

Architecture Highlights

Models Layer

Defines data structures and basic operations:

// models/product.unna
struct Product {
    id;
    name;
    price;
    stock;
}

function createProduct(name, price, stock) {
    return Product(nextId(), name, price, stock);
}

Services Layer

Contains business logic and imports from models:

// services/sales.unna
import "../models/order.unna" as orderLib;
import "../utils/logger.unna" as log;

function processSale(customer, order) {
    log.logInfo("Processing order...");
    orderLib.updateOrderStatus(order, "completed");
}

Utils Layer

Provides shared utilities used across the system:

// utils/logger.unna
function logInfo(module, msg) {
    print("[INFO] [" + module + "] " + msg);
}

Output

============================================================
  SME STORE MANAGEMENT SYSTEM
  Version 1.0 - Powered by Unnarize
============================================================

[INFO] [System] Starting SME Store System...
[INFO] [Reports] Generating report: INVENTORY SETUP
=== REPORT #1: INVENTORY SETUP ===
[1] Laptop Pro - $999 (Stock: 50)
[2] SmartPhone X - $599 (Stock: 100)
----------------------------------------

=== REPORT #2: CUSTOMER REGISTRATION ===
[1] Alice Johnson (Gold) - Balance: $2000
----------------------------------------

=== REPORT #3: ORDER PROCESSING ===
[OK] [Sales] Order #1 completed - Final: $999
----------------------------------------

============================================================
  SYSTEM COMPLETE
============================================================

Key Concepts Demonstrated