# Inventory Management System

A comprehensive inventory management system built with Vue 3 frontend and PHP backend, featuring inventory tracking, client management, project management, bookkeeping, and authentication.

## 🚀 **Latest Features**

### **Core Inventory Management**
- **Item Management** - Full CRUD operations with serial number tracking
- **Picture Upload** - Image attachment system for inventory items
- **Rental Pricing** - Dynamic pricing with date ranges and client assignments
- **Document Attachments** - Multi-format document management (Receipt, Warranty, Other)

### **Advanced Client Management**
- **Customer Profiles** - Complete contact information with y-tunnus support
- **Contact Persons** - Individual contact management with primary contact designation
- **Hourly Rates** - Customer-specific billing rates for project management
- **Address Management** - Full address support with international formatting

### **Project & Subproject Management**
- **Project Tracking** - Customer project management with status monitoring
- **Subproject Breakdown** - Detailed task management within projects
- **Progress Monitoring** - Visual progress bars and completion tracking
- **Budget Management** - Financial control and cost tracking
- **Date Range Management** - Start and end date tracking

### **Financial Management**
- **Invoice System** - Complete billing with line items and payment tracking
- **Payment Processing** - Multiple payment methods (Cash, Check, Credit Card, Bank Transfer)
- **Double-Entry Bookkeeping** - Professional accounting with debit/credit tracking
- **Chart of Accounts** - Hierarchical account structure (Assets, Liabilities, Equity, Revenue, Expenses)
- **Journal Entries** - Transaction recording with automatic entry numbering

### **Timer Management & Work Hours**
- **Real-time Timer** - Start/stop timer functionality with accurate time tracking
- **Task-based Timing** - Assign timers to specific tasks for project time tracking
- **Duration Display** - Shows elapsed time in HH:MM:SS format with timezone handling
- **Timer Editing** - Update timer descriptions and task assignments
- **Work Hours Conversion** - Automatically convert timers to billable work hours
- **Rate Integration** - Automatic rate fetching from task → project → customer data
- **Total Amount Calculation** - Automatic calculation of hours × rate for billing
- **Timer History** - Complete audit trail of all timer activities
- **Conditional UI** - Smart buttons showing "Aloita ajastin" / "Pysäytä" based on timer state

### **Enterprise Security**
- **User Authentication** - Secure login with password hashing
- **Role-Based Access** - Admin, Manager, User roles
- **Session Management** - Secure session handling and automatic cleanup
- **API Protection** - Middleware-based endpoint security

## 🏗 **Technology Stack**

### **Frontend**
- **Vue 3** - Progressive JavaScript framework
- **Axios** - HTTP client for API communication
- **Vite** - Fast development server
- **TailwindCSS** - Utility-first CSS framework
- **Responsive Design** - Mobile-friendly interface

### **Backend**
- **PHP 7.4+** - Modern server-side language
- **MySQL/MariaDB** - Reliable database system
- **RESTful API** - Standard HTTP methods and JSON responses
- **PDO** - Secure database connections
- **Password Hashing** - PHP's built-in security functions

## 📋 **Database Schema**

The system uses a normalized database structure with proper relationships:

### **Core Tables**
- **items** - Inventory with serial numbers and pictures
- **clients** - Customer management with y-tunnus and hourly rates
- **contact_persons** - Individual contacts linked to clients
- **rental_prices** - Item pricing with date ranges and client assignments
- **attachments** - Document management with categorization

### **Financial Tables**
- **invoices** - Billing with line items and payment tracking
- **invoice_items** - Detailed invoice line items
- **payments** - Transaction recording with multiple payment methods

### **Project Management Tables**
- **projects** - Customer project management with status tracking
- **subprojects** - Detailed project breakdown and task management
- **tasks** - Individual task management with project assignments

### **Timer & Work Hours Tables**
- **timers** - Real-time timer tracking with task assignments
- **work_hours** - Billable work hours with automatic rate calculation

### **Bookkeeping Tables**
- **chart_of_accounts** - Hierarchical account structure
- **journal_entries** - Double-entry transaction recording
- **account_transactions** - Detailed debit/credit tracking

### **Authentication Tables**
- **users** - Secure user management with role-based access

## 🚀 **Getting Started**

### **Prerequisites**
- Docker and Docker Compose (recommended)
- OR PHP 7.4+ with MySQL/MariaDB extension
- Node.js 14+ and npm (for development)
- Modern web browser (Chrome, Firefox, Safari, Edge)

### **Quick Setup**

#### **Option 1: Docker Deployment (Recommended)**

##### **Basic Setup (External Database)**
1. **Clone the repository:**
   ```bash
   git clone <repository-url>
   cd inventory
   ```

2. **Configure database connection:**
   ```bash
   # Copy and edit environment file
   cp backend/.env.local backend/.env.local
   nano backend/.env.local
   
   # Set your external database credentials:
   DB_HOST=your_database_host
   DB_NAME=inventory_db
   DB_USER=your_username
   DB_PASS=your_password
   ```

3. **Start the application:**
   ```bash
   docker-compose up -d
   ```

4. **Access Application:**
   - Frontend: `http://localhost:80`

##### **Full Setup (Built-in Database + Cache)**
1. **Clone the repository:**
   ```bash
   git clone <repository-url>
   cd inventory
   ```

2. **Start with built-in services:**
   ```bash
   docker-compose -f docker-compose-with-services.yml --env-file .env.with-services up -d
   ```

3. **Access Application:**
   - Frontend: `http://localhost:80`
   - Database: MariaDB on port 3306
   - Redis Cache: Redis on port 6379

#### **Option 2: Manual Installation**
1. **Clone the repository:**
   ```bash
   git clone <repository-url>
   cd inventory
   ```

2. **Database Setup:**
   ```bash
   # Create database and import complete schema
   mysql -u root -p < backend/setup_database.sql
   
   # Update database credentials
   nano backend/config/database.php
   ```

3. **Backend Server:**
   ```bash
   cd backend
   php -S localhost:8080
   ```

4. **Frontend Setup:**
   ```bash
   cd frontend
   npm install
   npm run dev -- --host 0.0.0.0 --port 3000
   ```

5. **Access Application:**
   - Backend: `http://localhost:8080` (API)
   - Frontend: `http://localhost:3000` (Web Interface)

#### **Option 2: Existing Database Upgrade**
1. **Backup existing database:**
   ```bash
   mysqldump -u root -p inventory_db > backup.sql
   ```

2. **Run migration script:**
   ```bash
   mysql -u root -p inventory_db < backend/migrate_complete.sql
   ```

3. **Restart services:**
   ```bash
   # Restart PHP server if running
   sudo systemctl restart apache2
   # or
   sudo systemctl restart nginx
   ```

## 🔧 **Configuration**

### **Docker Environment Variables**

#### **Basic Setup (.env.local)**
```bash
# Database Configuration
DB_HOST=your_database_host
DB_PORT=3306
DB_NAME=inventory_db
DB_USER=your_username
DB_PASS=your_password

# Company Information
COMPANY_NAME=Inventory Management
COMPANY_ADDRESS=123 Business St
COMPANY_CITY=Helsinki
COMPANY_COUNTRY=Finland
COMPANY_PHONE=+358 123 456 789
COMPANY_EMAIL=info@company.com
COMPANY_Y_TUNNUS=1234567-8

# File Upload Configuration
UPLOAD_MAX_SIZE=10M
ALLOWED_FILE_TYPES=pdf,doc,docx,xls,xlsx,jpg,jpeg,png,gif
UPLOADS_PATH=./uploads
```

#### **Full Services Setup (.env.with-services)**
```bash
# Database Configuration (Built-in MariaDB)
DB_HOST=mariadb
DB_PORT=3306
DB_NAME=inventory_db
DB_USER=inventory_user
DB_PASS=inventory_password
MYSQL_ROOT_PASSWORD=root_password

# Redis Configuration (Built-in Redis)
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=redis_password

# Frontend Configuration
FRONTEND_PORT=80
MARIADB_PORT=3306
REDIS_PORT=6379
```

### **Manual Database Configuration**
For manual installation, update `backend/config/database.php`:
```php
<?php
class Database {
    private $host = "localhost";
    private $db_name = "inventory_db";
    private $username = "root";
    private $password = "your_password";
    
    public function getConnection() {
        $conn = null;
        
        try {
            $conn = new PDO(
                "mysql:host={$this->host};dbname={$this->db_name}", 
                $this->username, 
                $this->password
            );
            
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
            
            return $conn;
        } catch(PDOException $exception) {
            echo "Connection error: " . $exception->getMessage();
            return null;
        }
    }
}
?>
```

### **Environment Variables (Recommended)**
Create `.env` file for sensitive configuration:
```env
DB_HOST=localhost
DB_NAME=inventory_db
DB_USER=root
DB_PASSWORD=your_password
```

### **Frontend Configuration**
Update `frontend/src/main.js` if needed for different API endpoints:
```javascript
axios.defaults.baseURL = 'http://localhost:8000/api';
```

## 📚 **API Documentation**

### **Authentication Endpoints**
- **POST** `/api/auth.php` - Login, Register, Logout
  ```json
  {
    "action": "login|register|logout",
    "username": "string",
    "password": "string",
    "email": "string",
    "first_name": "string",
    "last_name": "string"
  }
  ```

- **GET** `/api/auth.php?action=status` - Check authentication status

### **Item Management**
- **GET** `/api/items.php` - List all items
- **GET** `/api/items.php?id={id}` - Get single item
- **POST** `/api/items.php` - Create new item
- **PUT** `/api/items.php` - Update existing item
- **DELETE** `/api/items.php?id={id}` - Delete item

### **Client Management**
- **GET** `/api/clients.php` - List all clients
- **GET** `/api/clients.php?id={id}` - Get single client
- **GET** `/api/clients.php?search={term}` - Search clients
- **POST** `/api/clients.php` - Create new client
- **PUT** `/api/clients.php` - Update existing client
- **DELETE** `/api/clients.php?id={id}` - Delete client

### **Contact Persons**
- **GET** `/api/contact_persons.php?client_id={id}` - Get contact persons for client
- **GET** `/api/contact_persons.php?id={id}` - Get single contact person
- **POST** `/api/contact_persons.php` - Create new contact person
- **PUT** `/api/contact_persons.php` - Update existing contact person
- **DELETE** `/api/contact_persons.php?id={id}` - Delete contact person

### **Timer Management**
- **GET** `/api/timers.php?action=active` - Get active timers
- **GET** `/api/timers.php?action=list` - Get timer history
- **POST** `/api/timers.php` - Start new timer
  ```json
  {
    "action": "start",
    "task_id": 1,
    "user_id": 1,
    "description": "Timer description"
  }
  ```
- **POST** `/api/timer_stop.php` - Stop timer
  ```json
  {
    "action": "stop",
    "id": 1
  }
  ```
- **POST** `/api/timer_update.php` - Update timer (convert to work hours)
  ```json
  {
    "action": "update",
    "id": 1,
    "description": "Updated description",
    "task_id": 1,
    "hours": 2.5
  }
  ```
- **GET** `/api/timer_history.php` - Get timer history with filters

### **Work Hours Management**
- **GET** `/api/work_hours.php` - Get work hours
- **POST** `/api/work_hours.php` - Create work hour entry
- **PUT** `/api/work_hours.php` - Update work hour entry
- **DELETE** `/api/work_hours.php?id={id}` - Delete work hour entry

### **Rental Prices**
- **GET** `/api/rental_prices.php?item_id={id}` - Get rental prices for item
- **GET** `/api/rental_prices.php?id={id}` - Get single rental price
- **POST** `/api/rental_prices.php` - Create new rental price
- **PUT** `/api/rental_prices.php` - Update existing rental price
- **DELETE** `/api/rental_prices.php?id={id}` - Delete rental price

### **Document Attachments**
- **GET** `/api/attachments.php?item_id={id}` - Get attachments for item
- **GET** `/api/attachments.php?id={id}` - Get single attachment
- **POST** `/api/attachments.php` - Upload attachment file
- **DELETE** `/api/attachments.php?id={id}` - Delete attachment

### **File Upload**
- **POST** `/api/upload.php` - Upload picture files
  - Form: `multipart/form-data`
  - Max size: 5MB

### **Project Management**
- **GET** `/api/projects.php` - List all projects
- **GET** `/api/projects.php?id={id}` - Get single project
- **GET** `/api/projects.php?customer_id={id}` - Get projects for customer
- **POST** `/api/projects.php` - Create new project
- **PUT** `/api/projects.php` - Update existing project
- **DELETE** `/api/projects.php?id={id}` - Delete project

### **Subproject Management**
- **GET** `/api/subprojects.php?project_id={id}` - Get subprojects for project
- **GET** `/api/subprojects.php?id={id}` - Get single subproject
- **POST** `/api/subprojects.php` - Create new subproject
- **PUT** `/api/subprojects.php` - Update existing subproject
- **DELETE** `/api/subprojects.php?id={id}` - Delete subproject

### **Financial Management**
- **GET** `/api/invoices.php` - List all invoices
- **GET** `/api/invoices.php?id={id}` - Get single invoice with items and payments
- **POST** `/api/invoices.php` - Create new invoice
- **PUT** `/api/invoices.php` - Update existing invoice
- **DELETE** `/api/invoices.php?id={id}` - Delete invoice

### **Bookkeeping**
- **GET** `/api/chart_of_accounts.php` - List chart of accounts
- **GET** `/api/chart_of_accounts.php?id={id}` - Get single account
- **POST** `/api/chart_of_accounts.php` - Create new account
- **PUT** `/api/chart_of_accounts.php` - Update existing account
- **DELETE** `/api/chart_of_accounts.php?id={id}` - Delete account

- **GET** `/api/journal_entries.php` - List journal entries
- **GET** `/api/journal_entries.php?id={id}` - Get single journal entry with transactions
- **POST** `/api/journal_entries.php` - Create new journal entry with transactions
- **PUT** `/api/journal_entries.php` - Update existing journal entry
- **DELETE** `/api/journal_entries.php?id={id}` - Delete journal entry

- **GET** `/api/account_transactions.php?journal_entry_id={id}` - Get transactions for journal entry
- **GET** `/api/account_transactions.php?id={id}` - Get single transaction
- **POST** `/api/account_transactions.php` - Create new transaction
- **PUT** `/api/account_transactions.php` - Update existing transaction
- **DELETE** `/api/account_transactions.php?id={id}` - Delete transaction

## 🎯 **Usage Examples**

### **Authentication**
```javascript
// Login
const loginResponse = await axios.post('/api/auth.php', {
  action: 'login',
  username: 'admin',
  password: 'password123'
});

// Register
const registerResponse = await axios.post('/api/auth.php', {
  action: 'register',
  username: 'newuser',
  email: 'user@example.com',
  password: 'password123',
  first_name: 'John',
  last_name: 'Doe'
});

// Check authentication status
const authStatus = await axios.get('/api/auth.php?action=status');
```

### **Item Management**
```javascript
// Get all items
const items = await axios.get('/api/items.php');

// Create new item with picture
const formData = new FormData();
formData.append('name', 'Laptop');
formData.append('description', 'High-performance laptop');
formData.append('quantity', 10);
formData.append('price', 1299.99);
formData.append('serial_number', 'LP001');
formData.append('picture', fileInput.files[0]); // File upload

const newItem = await axios.post('/api/items.php', formData, {
  headers: {
    'Content-Type': 'multipart/form-data'
  }
});
```

### **Timer Management**
```javascript
// Start a new timer for a task
const startTimer = await axios.post('/api/timers.php', {
  action: 'start',
  task_id: 1,
  user_id: 1,
  description: 'Working on project setup'
});

// Get active timers
const activeTimers = await axios.get('/api/timers.php?action=active');

// Stop a timer
const stopTimer = await axios.post('/api/timer_stop.php', {
  action: 'stop',
  id: 1
});

// Update timer and convert to work hours
const updateTimer = await axios.post('/api/timer_update.php', {
  action: 'update',
  id: 1,
  description: 'Updated description',
  task_id: 1,
  hours: 2.5
});

// Get timer history
const timerHistory = await axios.get('/api/timer_history.php');
```

### **Client Management**
```javascript
// Create new client with y-tunnus
const newClient = await axios.post('/api/clients.php', {
  y_tunnus: '1234567-8',
  company_name: 'Tech Corp',
  first_name: 'Jane',
  last_name: 'Smith',
  email: 'jane@techcorp.com',
  hour_price: 150.00,
  address: '123 Business St',
  city: 'Helsinki',
  country: 'Finland'
});

// Add contact person
const newContact = await axios.post('/api/contact_persons.php', {
  client_id: 1,
  first_name: 'John',
  last_name: 'Doe',
  email: 'john.doe@techcorp.com',
  position: 'Project Manager',
  is_primary: true
});
```

### **Project Management**
```javascript
// Create new project
const newProject = await axios.post('/api/projects.php', {
  customer_id: 1,
  project_name: 'Website Redesign',
  description: 'Complete website overhaul project',
  status: 'planning',
  start_date: '2024-01-15',
  end_date: '2024-03-15',
  budget: 50000.00
});

// Add subproject
const newSubproject = await axios.post('/api/subprojects.php', {
  project_id: 1,
  subproject_name: 'Frontend Development',
  description: 'Create responsive frontend design',
  status: 'in_progress',
  budget: 15000.00
});
```

### **Financial Management**
```javascript
// Create invoice with line items
const newInvoice = await axios.post('/api/invoices.php', {
  client_id: 1,
  invoice_number: 'INV-2024-001',
  issue_date: '2024-01-15',
  due_date: '2024-02-15',
  status: 'sent',
  subtotal: 10000.00,
  tax_amount: 2400.00,
  total_amount: 12400.00,
  transactions: [
    {
      account_id: 1, // Revenue account
      debit_amount: 0,
      credit_amount: 12400.00,
      description: 'Website redesign services'
    },
    {
      account_id: 2, // Bank account
      debit_amount: 12400.00,
      credit_amount: 0,
      description: 'Payment received'
    }
  ]
});
```

### **Bookkeeping**
```javascript
// Create journal entry with double-entry
const newJournalEntry = await axios.post('/api/journal_entries.php', {
  entry_number: 'JE-2024-001',
  entry_date: '2024-01-15',
  description: 'Monthly revenue entry',
  reference_number: 'REF-001',
  transactions: [
    {
      account_id: 1, // Revenue account
      debit_amount: 15000.00,
      credit_amount: 0,
      description: 'Service revenue'
    },
    {
      account_id: 2, // Bank account
      debit_amount: 0,
      credit_amount: 15000.00,
      description: 'Bank deposit'
    }
  ]
});
```

## ⏱️ **Timer Workflow & Features**

### **Complete Timer Lifecycle**
1. **Start Timer**: Begin timing for a specific task with description
2. **Real-time Display**: Shows elapsed time in HH:MM:SS format
3. **Stop Timer**: End timing and calculate duration
4. **Edit Timer**: Update description and task assignment
5. **Convert to Work Hours**: Move to billable work hours with automatic rate calculation
6. **Rate Integration**: Automatically fetch rate from task → project → customer data

### **Timer Management Features**
- **Task-based Timing**: Assign timers to specific tasks for project tracking
- **Timezone Handling**: Proper UTC timestamp conversion for accurate timing
- **Duration Calculation**: Automatic conversion to hours (rounded to nearest 0.5 hour)
- **Conditional UI**: Smart buttons showing "Aloita ajastin" / "Pysäytä" based on timer state
- **Timer History**: Complete audit trail of all timer activities
- **Work Hours Integration**: Seamless conversion to billable work hours

### **Work Hours Management**
- **Automatic Rate Fetching**: Rate retrieved from customer data through task/project relationships
- **Total Amount Calculation**: Automatic calculation of hours × rate for billing
- **Database Integration**: Uses existing WorkHour model for data consistency
- **Audit Trail**: Complete history of work hour entries with timer origins

### **User Interface Enhancements**
- **Wider Layout**: 20% wider application for better user experience
- **Simplified Forms**: Clean timer edit modal with only essential fields
- **Real-time Updates**: Button states update when timers start/stop
- **Finnish Language**: Consistent Finnish labels throughout the interface

## 🔒 **Security Considerations**

### **Authentication Security**
- Password hashing using PHP's `password_hash()` function
- Session-based authentication with secure session management
- SQL injection prevention with prepared statements
- Input sanitization with `htmlspecialchars()`
- CORS headers for cross-origin requests

### **API Security**
- Request validation and error handling
- Role-based access control (Admin, Manager, User)
- Secure file upload with file type and size validation
- Database transaction integrity with foreign key constraints

## 🎨 **Frontend Features**

### **User Interface**
- **Responsive Design** - Mobile-friendly layout
- **Real-time Updates** - Live data synchronization
- **Modal Dialogs** - User-friendly forms and confirmations
- **Search Functionality** - Global search across all entities
- **Status Indicators** - Visual badges and progress bars
- **Tabbed Navigation** - Organized interface sections

### **Interactive Elements**
- **Drag & Drop** - File upload and organization
- **Auto-complete** - Smart form suggestions
- **Date Pickers** - Calendar-based date selection
- **Rich Text Editors** - Enhanced text input areas

## 📊 **Data Management**

### **Import/Export**
- CSV export functionality for reports
- Data backup and restore capabilities
- Bulk operations for efficiency

### **Reporting**
- Financial reports with charts and graphs
- Inventory reports with stock levels and values
- Project progress reports with timelines
- Customer activity reports with engagement metrics

## 🚀 **Deployment**

### **Production Setup**
1. **Environment Configuration**
   ```bash
   export NODE_ENV=production
   export DB_HOST=your-production-host
   ```

2. **Web Server Configuration**
   - Apache with mod_rewrite for clean URLs
   - Nginx with PHP-FPM for performance
   - SSL/TLS certificates for HTTPS

3. **Database Optimization**
   - Enable query caching
   - Configure connection pooling
   - Set up read replicas for scaling

### **Monitoring**
- Application performance monitoring
- Database query performance tracking
- Error logging and alerting
- User activity analytics

## 📄 **License**

This project is licensed under the MIT License - feel free to use, modify, and distribute according to your needs.

---

**Last Updated:** April 2026
**Version:** 2.0.0
**Compatible with:** PHP 7.4+, MySQL 5.7+, Node.js 14+, Vue 3

## 🗂 **Project Structure**

```
inventory/
├── backend/
│   ├── config/
│   │   └── database.php
│   ├── models/
│   │   ├── Item.php
│   │   ├── RentalPrice.php
│   │   ├── Attachment.php
│   │   ├── Client.php
│   │   ├── ContactPerson.php
│   │   ├── Project.php
│   │   ├── Subproject.php
│   │   ├── ChartOfAccounts.php
│   │   ├── JournalEntry.php
│   │   ├── AccountTransaction.php
│   │   └── User.php
│   ├── api/
│   │   ├── items.php
│   │   ├── rental_prices.php
│   │   ├── attachments.php
│   │   ├── clients.php
│   │   ├── contact_persons.php
│   │   ├── projects.php
│   │   ├── subprojects.php
│   │   ├── invoices.php
│   │   ├── chart_of_accounts.php
│   │   ├── journal_entries.php
│   │   ├── account_transactions.php
│   │   ├── auth.php
│   │   └── upload.php
│   ├── migrate_complete.sql
│   ├── migrate_y_tunnus.sql
│   ├── migrate_new_tables.sql
│   ├── migrate_clients.sql
│   ├── migrate_projects.sql
│   ├── migrate_bookkeeping.sql
│   └── migrate_auth.sql
├── frontend/
│   ├── src/
│   │   ├── App.vue
│   │   └── main.js
│   ├── index.html
│   ├── package.json
│   └── vite.config.js
└── README.md
```

## 🎓 **Support & Maintenance**

### **Regular Updates**
- Security patches and updates
- Feature enhancements based on user feedback
- Performance optimizations
- Database maintenance and optimization

### **Backup Strategy**
- Automated daily database backups
- File system backups
- Disaster recovery planning

### **Troubleshooting**
- Common issues and solutions
- Performance tuning guides
- Security best practices
- Debugging techniques

## 📄 **Migration Scripts**

### **Complete Migration**
For new installations, use the complete migration script:
```bash
mysql -u root -p < backend/migrate_complete.sql
```

### **Individual Migrations**
For upgrading existing installations:
```bash
# Add y-tunnus and contact persons
mysql -u root -p < backend/migrate_y_tunnus.sql

# Add rental prices and attachments
mysql -u root -p < backend/migrate_new_tables.sql

# Add client management
mysql -u root -p < backend/migrate_clients.sql

# Add project management
mysql -u root -p < backend/migrate_projects.sql
- `postal_code` - Postal code (optional)
- `country` - Country (optional)
- `notes` - Additional notes (optional)
- `created_at` - Creation timestamp
- `updated_at` - Last update timestamp

### Contact Persons Table
- `id` - Primary key
- `client_id` - Foreign key to clients table
- `first_name` - First name (required)
- `last_name` - Last name (required)
- `email` - Email address (optional)
- `phone` - Phone number (optional)
- `position` - Job position/title (optional)
- `is_primary` - Primary contact flag (boolean)
- `created_at` - Creation timestamp
- `updated_at` - Last update timestamp

## File Upload

### Pictures
- Uploaded to `backend/api/uploads/` directory
- Supported formats: JPEG, PNG, GIF, WebP
- Maximum file size: 5MB
- Files are automatically renamed with unique IDs

### Attachments
- Uploaded to `backend/api/attachments/` directory
- Supported formats: PDF, DOC, DOCX, TXT, JPEG, PNG, GIF
- Maximum file size: 10MB
- Files are automatically renamed with unique IDs
- Documents are categorized by type (receipt, warranty, other)