# Quick Start Guide

## Getting Started in 5 Minutes

### 1. Start the Server
```bash
npm start
```

You should see:
```
Server running on http://localhost:3000
Admin: admin@chocolate.com / admin123
Customer: customer@example.com / customer123
```

### 2. Access the Application
Open your browser and go to: **http://localhost:3000**

### 3. First Time Setup (Admin)

#### Step 1: Login as Admin
- Email: `admin@chocolate.com`
- Password: `admin123`

#### Step 2: Add Your First Product
1. Click "Add Product" button
2. Fill in:
   - Name: "Dark Chocolate Bar 70%"
   - Description: "Premium Greek dark chocolate"
   - Weight: 0.5 (kg)
   - Markup: 30 (%)
3. Upload an image (optional)
4. Click "Save Product"

Repeat for more products (e.g., Milk Chocolate, White Chocolate, etc.)

#### Step 3: Calculate Import Pricing
1. Go to "Cost Calculator" tab
2. Enter:
   - Batch Name: "First Import"
   - Total Transport Cost: 500 (euros)
3. Click "Add Product" and fill in for each product:
   - Select product from dropdown
   - Quantity: 50
   - Purchase Cost: 3.50 (per unit)
   - Processing Cost: 0.50 (per unit)
4. Click "Calculate Prices" to see the breakdown
5. Review the calculated prices
6. Click "Save to Products" to apply the pricing

**What happens:** The system will:
- Distribute the €500 transport cost based on product weights
- Add purchase + processing + transport costs
- Apply the 30% markup
- Save final prices to each product

#### Step 4: Make Products Visible
Products are now priced and active. Customers can see and order them.

### 4. Test Customer Experience

#### Step 1: Logout and Login as Customer
- Logout from admin panel
- Login with:
  - Email: `customer@example.com`
  - Password: `customer123`

#### Step 2: Browse and Order
1. Browse available products
2. Select quantity and click "Add to Cart"
3. Go to "Cart" tab
4. Review your order
5. Click "Submit Order"

#### Step 3: View Orders
- Check "My Orders" tab to see order history

### 5. Manage Orders (Admin)

Switch back to admin account:
1. Go to "All Orders" tab
2. See all customer orders
3. Change order status using dropdown:
   - Pending → Processing → Completed

### Key Concepts

#### Transport Cost Distribution
The system splits transport costs **by weight**:

**Example:**
- Product A: 50 units × 0.5kg = 25kg
- Product B: 50 units × 0.3kg = 15kg
- Total: 40kg
- Transport: €500

Product A gets: (25kg / 40kg) × €500 = €312.50 total = €6.25/unit
Product B gets: (15kg / 40kg) × €500 = €187.50 total = €3.75/unit

#### Price Calculation
```
Final Price = (Purchase + Processing + Transport) × (1 + Markup%)

Example:
- Purchase: €3.50
- Processing: €0.50
- Transport: €6.25
- Total Cost: €10.25
- Markup: 30%
- Final Price: €10.25 × 1.30 = €13.33
```

#### Updating Individual Product Prices
You can edit any product later:
1. Go to "Products" tab
2. Click "Edit" on a product
3. The system recalculates automatically when you save

### Common Workflows

#### Workflow 1: New Import Shipment
1. Admin adds new products (if needed)
2. Admin goes to Cost Calculator
3. Enters transport cost and product details
4. Calculates and saves pricing
5. Products are ready for customer orders

#### Workflow 2: Price Update for Single Product
1. Admin goes to "Products" tab
2. Clicks "Edit" on the product
3. Updates purchase cost or processing cost
4. System recalculates final price automatically
5. Saves changes

#### Workflow 3: Customer Orders
1. Customer browses products
2. Adds items to cart
3. Submits order
4. Admin receives order
5. Admin processes and updates status
6. Customer can track status in order history

### Tips

- **Images**: Add product images to make the catalog attractive
- **Batch Names**: Use descriptive names like "March 2024 Import" for tracking
- **Markup**: Adjust markup % per product if needed (luxury vs. standard items)
- **Order Status**: Keep customers informed by updating order status promptly
- **Import History**: Review past batches to analyze cost trends

### Troubleshooting

**Problem**: Can't see products as customer
- **Solution**: Make sure products are set to "Active" in admin panel

**Problem**: Prices seem wrong
- **Solution**: Check that you entered costs correctly in the calculator

**Problem**: Can't upload images
- **Solution**: Make sure image is under 5MB and is .jpg, .png, or .gif

**Problem**: Forgot admin password
- **Solution**: Stop server, delete `database.db`, restart server (resets to defaults)

### Next Steps

Now you're ready to:
- Add all your chocolate products
- Calculate pricing for your actual import costs
- Invite customers to place orders
- Manage your chocolate import business!

### Need Help?

Refer to the full [README.md](README.md) for:
- Complete API documentation
- Database schema details
- Customization options
- Security recommendations for production use
