<p align="center">
    <a href="https://ipsitasoft.com" target="_blank">
        <img src="https://github.com/ipsita-soft.png" width="150" alt="ICPL Logo">
    </a>
</p>

<h1 align="center">BTS ERP System</h1>
<h3 align="center">Bangladesh Thalassaemia Samity (BTS)</h3>
<p align="center">
Enterprise Resource Planning (ERP) Solution for Healthcare & Organizational Management
</p>

---

# 🏥 BTS ERP – Bangladesh Thalassaemia Samity

The **BTS ERP System** is a modular, scalable, and secure Enterprise Resource Planning solution developed for **Bangladesh Thalassaemia Samity (BTS)**.

This system streamlines hospital operations, patient lifecycle management, billing, HR, accounts, pharmacy, inventory, and laboratory tracking through a centralized digital platform.

Developed & Maintained by:
**Ipsita Computers Pte Ltd. (ICPL)**
🌐 Website: https://ipsitasoft.com

---

# 🚀 Technology Stack

| Configuration     | Version                              |
| ----------------- | -------------------------------------|
| Framework         | Laravel ^12.0                        |
| PHP               | 8.3                                  |
| Database          | MySQL                                |
| Authentication    | JWT (php-open-source-saver/jwt-auth) |
| Role & Permission | Spatie Laravel Permission (RBAC)     |
| Modular System    | Nwidart Laravel Modules              |
| Architecture      | Modular Monolith (Service Pattern)   |

---

# 🧩 System Architecture

The system follows a **Modular Monolith Architecture** using `nwidart/laravel-modules`.
<p>Each module is isolated with:</p>

- Controllers
- Services
- Repositories
- Models
- Policies
- Routes
- Requests
- Resources
- Seeders

---

# 📦 Core Modules

## 1️⃣ Patient Management

- Patient Registration
- Medical History Tracking
- Blood Group & Transfusion Records
- Appointment Scheduling
- Patient Status Monitoring

## 2️⃣ Billing & Report Management

- Invoice Generation
- Payment Tracking
- Due Management
- Financial Reports
- Patient Billing History

## 3️⃣ HR & Payroll Management

- Employee Management
- Salary Structure
- Payroll Processing
- Designation & Department Control
- Increment & Allowance Tracking

## 4️⃣ Attendance Management

- Daily Attendance
- Shift Management
- Leave Tracking
- Overtime Monitoring

## 5️⃣ Pharmacy Product Management

- Medicine Catalog
- Batch Tracking
- Expiry Monitoring
- Stock Alerts
- Supplier Management

## 6️⃣ Inventory Management

- Stock Management
- Product Purchase
- Warehouse Tracking
- Damage & Adjustment Logs

## 7️⃣ Lab Tracking Management

- Lab Test Registration
- Report Entry
- Sample Tracking
- Lab Report History

## 8️⃣ Accounts & Finance Management

- Chart of Accounts
- Ledger Management
- Income & Expense Tracking
- Cash & Bank Management
- Financial Statements

---

# 🔐 Security & Authentication

- JWT-based API Authentication
- Role-Based Access Control (RBAC) using Spatie
- Policy & Gate Authorization
- Global Middleware Protection
- Transaction-Based Database Operations
- Soft Deletes Enabled

---

# ⚙️ Installation Guide

1️⃣ Clone Repository
    git clone https://github.com/ipsita-soft/bts-erp.git

2️⃣ Install Dependencies

    composer install

Or update composer:

    composer update

3️⃣ Setup Environment File

    cp .env.example .env

4️⃣ Generate Application Key

    php artisan key:generate

5️⃣ Generate JWT Secret

    php artisan jwt:secret

6️⃣ Run Migration

    php artisan migrate

7️⃣ Run Seeders

    php artisan db:seed

8️⃣ Serve Application

    php artisan serve

## 🧪 Artisan Commands (Basic)

```bash
    php artisan serve
    php artisan migrate
    php artisan migrate:fresh --seed
    php artisan storage:link
    php artisan route:list
    php artisan cache:clear
    php artisan config:clear
    php artisan optimize:clear
    php artisan clear-compiled
    php artisan permission:cache-reset
```

## 📁 Project Structure (Modular)

```text
    Modules/
    ├── Patient/
    ├── Billing/
    ├── HR/
    ├── Attendance/
    ├── Pharmacy/
    ├── Inventory/
    ├── Lab/
    ├── Accounts/

    Each module contains/
    ├── Controllers/
    ├── Services/
    ├── Repositories/
    ├── Models/
    ├── Policies/
    ├── Routes/
    ├── Database/
```

## 🧱 Module Artisan Commands
```bash
    php artisan module:list
    php artisan module:make <ModuleName>
    php artisan module:enable <ModuleName>
    php artisan module:disable <ModuleName>
    php artisan module:delete <ModuleName>
    php artisan module:migrate <ModuleName>
    php artisan module:migrate-rollback <ModuleName>
    php artisan module:make-controller <ControllerName> <ModuleName>
    php artisan module:make-model <ModelName> <ModuleName>
    php artisan module:make-repository <RepositoryName> <ModuleName>
    php artisan module:make-service <ServiceName> <ModuleName>
    php artisan module:make-migration add_{column}_to_{table}_table <ModuleName>
```

## 🧠 Development Standards (ICPL Rules)

- Use Service Pattern
- Follow Repository Pattern
- Use Dependency Injection (IoC)
- Every DB Action must use DB::beginTransaction()
- Use Soft Delete
- Cascade On Delete for Foreign Keys
- Index Foreign Keys
- Use Custom Request for Validation
- Write Custom Validation Rules if reusable
- Use Resource/Collection for API Responses
- Paginate List Responses
- Eager Loading for Performance
- Use $fillable Not $guarded in Models
- Write Policy for Every Resource
- Write Proper Seeder
- Write Feature Test for Every Endpoint
- Use Markdown & Queue for Emails
- Store Uploaded Files in Storage (Not Public)
- Meaningful Commit Messages
- Do Not Push to Main Without Approval

## 📡 API Documentation (Postman)

The BTS ERP System APIs are documented using **Postman**.
- A Postman Collection is maintained for all modules.
- The collection includes:
  - Authentication APIs
  - Module-wise endpoints (Patient, Billing, HR, Accounts, etc.)
  - Request validation examples
  - Sample success & error responses
- Environment variables are used for:
  - Base URL
  - JWT Token
  - Organization-specific configuration

### Usage
1. Import the Postman collection.
2. Configure environment variables (`Base_url`, `token`).
3. Authenticate to obtain JWT.
4. Access secured endpoints using the token.

> Postman collections are maintained internally and shared with authorized developers only.

## 📝 Contribution Rules

- Developers must create a new branch using their own name or a feature-specific name before pushing any changes.
- Direct push to main or master is not allowed.
- After completing work, submit a Pull Request (PR) for review and approval.

## 👥 Contributors

- **[Arun Kumar](https://github.com/arunkroy)** Lead Architect & Backend Developer.
- **[MD Siddiqul Islam Labib](https://github.com/csesiddiqul)** Backend Developer.

## 📜 License

This project is proprietary software developed exclusively for
Bangladesh Thalassaemia Samity (BTS). Unauthorized distribution or resale is prohibited.

## 🏢 Developed By

Ipsita Computers Pte Ltd. ([ICPL](https://ipsitasoft.com))

🌐 ICPL Website: https://ipsitasoft.com

💼 GitHub: https://github.com/ipsita-soft

Specialized in ERP, Government Solutions & Healthcare Systems

---

❤️ Created with care & all rights reserved © **[ICPL](https://ipsitasoft.com)**
