# Z.CRM System
## نظام إدارة علاقات العملاء - نظام إدارة شامل

Enterprise-grade CRM system with 6 integrated modules:

1. **Contact Management** - إدارة جهات الاتصال
2. **CRM** - إدارة علاقات العملاء
3. **Inventory & Assets** - إدارة المستودعات والأصول
4. **Tasks & Projects** - إدارة المهام والمشاريع
5. **HR Management** - إدارة الموارد البشرية
6. **Marketing** - إدارة التسويق

## Tech Stack

### Backend
- Node.js + Express + TypeScript
- PostgreSQL with Prisma ORM
- JWT Authentication
- Role-based Access Control (RBAC)

### Frontend
- Next.js 14 with TypeScript
- Tailwind CSS
- RTL Support (Arabic/English)
- React Query for data fetching

## Installation

```bash
# Install all dependencies
npm run install-all

# Setup database
cd backend
cp .env.example .env
# Edit .env with your database credentials
npx prisma migrate dev
npx prisma generate
npx prisma db seed
```

## Development

```bash
# Run both backend and frontend
npm run dev

# Or run separately
npm run dev:backend  # Backend on port 5000
npm run dev:frontend # Frontend on port 3000
```

## Production

```bash
npm run build
npm start
```

## Project Structure

```
z_crm/
├── backend/           # Express API server
│   ├── src/
│   │   ├── modules/
│   │   │   ├── contacts/      # Module 1
│   │   │   ├── crm/           # Module 2
│   │   │   ├── inventory/     # Module 3
│   │   │   ├── projects/      # Module 4
│   │   │   ├── hr/            # Module 5
│   │   │   └── marketing/     # Module 6
│   │   ├── shared/
│   │   ├── auth/
│   │   └── config/
│   ├── prisma/
│   └── tests/
├── frontend/          # Next.js application
│   ├── src/
│   │   ├── app/
│   │   ├── components/
│   │   ├── modules/
│   │   └── lib/
│   └── public/
└── docs/             # Documentation
```

## Key Features

- ✅ Unified ID system for all contacts
- ✅ Duplicate detection and merging
- ✅ Complete audit logging
- ✅ Hierarchical organizational structure
- ✅ Multi-level approval workflows
- ✅ Role-based permissions from HR module
- ✅ 360° contact history
- ✅ Full Arabic & English support
- ✅ Document versioning
- ✅ Soft delete (archiving)
- ✅ Advanced search & filtering

## Security

- JWT-based authentication
- HR module controls all system access
- Field-level permissions
- Complete audit trail
- Data masking for sensitive info
- No default delete - archive only

## License

Proprietary - © مجموعة أتمتة

