# 🏢 ERP System - Full Stack Application

A comprehensive Enterprise Resource Planning (ERP) system for managing bookings, agents, suppliers, and financial transactions with a dynamic dashboard and real-time analytics.

![License](https://img.shields.io/badge/license-Private-red)
![Laravel](https://img.shields.io/badge/Laravel-11-red)
![React](https://img.shields.io/badge/React-18-blue)
![PHP](https://img.shields.io/badge/PHP-8.2-purple)

---

## 📁 Project Structure

This is a **monorepo** containing both frontend and backend:

```
erp-system/
├── ERP proj/              # React Frontend (Vite + TailwindCSS)
│   ├── src/              # React components and pages
│   ├── public/           # Static assets
│   └── package.json      # Frontend dependencies
│
├── erp-backend/          # Laravel Backend (API)
│   ├── app/              # Laravel application
│   ├── database/         # Migrations and seeders
│   ├── routes/           # API routes
│   └── composer.json     # Backend dependencies
│
├── .gitignore            # Git ignore rules
└── README.md             # This file
```

---

## ✨ Features

### 📊 Dynamic Dashboard
- Real-time statistics and analytics
- Interactive charts (Bar, Line, Pie)
- Date range filtering
- Financial summaries (Agent/Supplier amounts, Profit)
- Booking type distribution
- Daily revenue and booking trends

### 🏨 Booking Management
- **Hotel Bookings** - Room reservations with meal plans
- **Car Bookings** - Vehicle rentals with flight details
- **Service Bookings** - Custom service bookings
- Multi-booking support per transaction
- Booking status tracking (Confirmed/Cancelled)

### 💰 Financial Management
- Agent receivable payment tracking
- Supplier given payment tracking
- Credit/Cash transaction management
- Invoice generation with PDF export
- Payment vouchers
- Financial statements and reports

### 📄 Statement Reports
- Agent statements with payment status
- Supplier statements
- Employee statements
- Agent user statements
- Profit & Loss statements
- Customizable date ranges
- PDF export functionality

### 👥 User Management
- Agent management with user accounts
- Supplier management
- Guest management
- Employee management
- Role-based access control
- Authentication with Laravel Sanctum

---

## 🛠️ Tech Stack

### Frontend (`ERP proj/`)
- **Framework:** React 18
- **Build Tool:** Vite
- **Styling:** TailwindCSS
- **State Management:** Zustand
- **Charts:** Recharts
- **Icons:** Heroicons
- **HTTP Client:** Axios
- **Routing:** React Router DOM

### Backend (`erp-backend/`)
- **Framework:** Laravel 11
- **Language:** PHP 8.2+
- **Database:** MySQL
- **Authentication:** Laravel Sanctum
- **PDF Generation:** DomPDF
- **Architecture:** Repository Pattern, Service Layer

---

## 📋 Prerequisites

- **PHP** 8.2 or higher
- **Composer** (PHP dependency manager)
- **Node.js** 18+ and npm
- **MySQL** 8.0+
- **Git** (for version control)

---

## 🚀 Installation

### 1. Clone the Repository

```bash
git clone https://github.com/YOUR_USERNAME/erp-system.git
cd erp-system
```

### 2. Backend Setup

```bash
# Navigate to backend
cd erp-backend

# Install PHP dependencies
composer install

# Copy environment file
cp .env.example .env

# Generate application key
php artisan key:generate

# Configure database in .env
# DB_DATABASE=your_database
# DB_USERNAME=your_username
# DB_PASSWORD=your_password

# Run migrations
php artisan migrate

# Start Laravel server
php artisan serve
```

Backend will run on: `http://localhost:8000`

### 3. Frontend Setup

```bash
# Navigate to frontend (from project root)
cd "ERP proj"

# Install Node dependencies
npm install

# Start development server
npm run dev
```

Frontend will run on: `http://localhost:5173`

---

## 🌐 Access the Application

- **Frontend:** http://localhost:5173
- **Backend API:** http://localhost:8000/api
- **API Documentation:** See `erp-backend/routes/api.php`

---

## 📚 Documentation

- **Backend README:** `erp-backend/README.md`
- **Dashboard Implementation:** `erp-backend/DASHBOARD_DYNAMIC_IMPLEMENTATION.md`
- **GitHub Setup Guide:** `erp-backend/GITHUB_SETUP_FIX.md`
- **Push to GitHub Guide:** `erp-backend/PUSH_TO_GITHUB.md`

---

## 🔄 Development Workflow

### Making Changes

```bash
# Check status
git status

# Add changes
git add .

# Commit with descriptive message
git commit -m "Add feature: booking details modal"

# Push to GitHub
git push
```

### Running Both Servers

**Terminal 1 - Backend:**
```bash
cd erp-backend
php artisan serve
```

**Terminal 2 - Frontend:**
```bash
cd "ERP proj"
npm run dev
```

---

## 🏗️ Building for Production

### Backend
```bash
cd erp-backend
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

### Frontend
```bash
cd "ERP proj"
npm run build
```

---

## 📝 License

This project is proprietary and confidential.

---

## 👨‍💻 Author

**Your Name**
- GitHub: [@yourusername](https://github.com/yourusername)
- Email: your.email@example.com

---

## 🙏 Acknowledgments

- Laravel Framework
- React Team
- TailwindCSS
- Recharts
- All open-source contributors

---

**Made with ❤️ for efficient business management**

