Skip to content
UukowPublic

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

KeydUkun - Poultry ERP System

KeydUkun is a full-cycle poultry enterprise platform designed for hatchery operations, farm management, and financial control.
It tracks the process end-to-end: egg procurement -> incubation -> hatching -> chick growth -> inventory usage -> accounting -> reporting.

1) System Purpose

This system helps poultry businesses answer critical operational questions in one place:

  • What is the hatch success rate by batch and incubator?
  • How many chicks are currently alive, and where are they located?
  • Which stock items are low or near expiry?
  • Can we afford this expense or payroll run right now?
  • Which operation units are profitable or loss-making?

2) Technology Stack

Layer Technology
UI Layer PHP views, Bootstrap 5, jQuery, AJAX
API Layer PHP 7.4+ / 8.x REST-style JSON API
Data Layer MySQL 5.7+ / MariaDB 10.4+
Authentication JWT (custom implementation)
Mail/Alerts PHPMailer
Deployment Apache + .htaccess rewrite

3) High-Level Architecture

flowchart LR
    U[User Browser] --> V[PHP Views]
    V --> J[JS Modules]
    J --> A[REST API /api/v1]
    A --> C[Controllers]
    C --> H[Helpers + Middleware]
    H --> D[(MySQL / MariaDB)]
    C --> N[Notifications]
Loading

Request Lifecycle (bit by bit)

  1. User opens a page from views/ through Apache.
  2. Frontend JS module sends AJAX calls to /api/v1/....
  3. Middleware validates JWT and role permission.
  4. Controller validates payload and business rules.
  5. Database transaction is executed.
  6. JSON response returns to UI and updates state.
  7. Notification/log is created for important events.

4) Core Business Flow Diagram

flowchart TD
    S[Supplier] --> E[Egg Batch]
    E --> I[Incubation Session]
    I --> F[Fertility Check]
    F --> H[Hatching Record]
    H --> C[Chick Batch]
    C --> M[Mortality + Growth]
    M --> R[Performance Reports]

    E --> X[Egg Cost]
    X --> PnL[Profit and Loss]
    C --> Sales[Income]
    Sales --> PnL
Loading

5) Feature-by-Feature System Explanation

5.1 Hatchery and Egg Procurement

What it does

  • Maintains supplier records and egg sourcing history.
  • Creates egg batches with quantity, grade, and cost details.
  • Generates batch references for traceability.

Why it matters

  • Establishes data lineage from supplier to final profitability.
  • Improves quality control before incubation starts.

5.2 Incubation Lifecycle (Critical Module)

Stage model: placed -> fertility_check -> development -> hatching -> completed

What it does

  • Creates incubation sessions linked to egg batches and incubators.
  • Records environment and observation logs (temperature/humidity/notes).
  • Tracks fertile vs infertile eggs during checks.
  • Supports stage progression and expected hatch timelines.

Why it matters

  • Converts manual incubator notes into measurable outcomes.
  • Enables hatch-rate analytics by session, incubator, and source batch.

5.3 Hatching and Chick Management

What it does

  • Records hatch outcomes (hatched, dead-in-shell, infertile, early loss).
  • Automatically creates chick batches from hatch records.
  • Tracks cage assignment, growth, and mortality events.

Why it matters

  • Maintains continuity from incubation results to live flock operations.
  • Gives accurate alive-count and health trend visibility.

5.4 Inventory and Stock Control

What it does

  • Manages inventory items by category (feed, medicine, equipment, packaging).
  • Records stock movements and manual adjustments.
  • Flags low-stock levels and medicine expiry risks.

Why it matters

  • Prevents stock-out disruptions in feeding/treatment plans.
  • Supports better purchasing and wastage reduction.

5.5 Finance and Smart Balance Enforcement

sequenceDiagram
    participant UI as UI/API Caller
    participant F as Finance Controller
    participant DB as Accounts DB
    UI->>F: Create Expense(amount, account_id)
    F->>DB: Check current balance
    alt balance >= amount
        F->>DB: Insert expense + debit account
        F->>DB: Insert account transaction snapshot
        F-->>UI: Success
    else insufficient balance
        F-->>UI: Reject (validation error)
    end
Loading

What it does

  • Handles accounts, incomes, expenses, and transaction history.
  • Auto-credits balances on income and auto-debits on expense.
  • Blocks overspending at write-time.
  • Supports low-balance alerting and multi-account operations.

Why it matters

  • Protects cash integrity and prevents hidden negative balances.
  • Creates auditable financial movement trails.

5.6 HR and Payroll

What it does

  • Stores employee profiles and payroll history.
  • Supports advance payments and deduction tracking.
  • Generates payroll periods with validation checks.
  • Records salary payout impact in finance.

Why it matters

  • Unifies workforce cost control with accounting controls.
  • Reduces payroll calculation errors and unpaid liabilities.

5.7 Reports and Analytics

What it does

  • Profit and loss report by period/category.
  • Hatch rate analytics and batch performance.
  • Mortality report by cause and trend.
  • Cash flow trend and inventory valuation.

Why it matters

  • Turns raw transactions into decision-ready KPIs.
  • Helps managers optimize breeding, feed planning, and spending.

5.8 Security and Access Control

What it does

  • JWT authentication for API access.
  • Role-based permissions (Admin, Manager, Accountant, Worker).
  • Input validation and prepared statements.
  • Password hashing and login logging.

Why it matters

  • Protects operational and financial data from misuse.
  • Enforces least-privilege access by function.

6) API Overview

Base URL

http://localhost/dooro/api/v1/

Authentication

  • Login endpoint returns JWT tokens.
  • All protected endpoints require:

Authorization: Bearer <jwt-token>

Main API Domains

  • Auth: /auth/*
  • Hatchery: /batches, /suppliers
  • Incubation: /incubation/*, /incubators, /hatching/*
  • Chick Ops: /chicks, /cages, /mortality
  • Inventory: /inventory/*, /stock
  • Finance: /accounts, /incomes, /expenses
  • HR/Payroll: /employees, /payroll/*
  • Reports: /reports/*
  • System: /dashboard, /notifications, /users, /settings

API Response Pattern

{
  "success": true,
  "data": {},
  "message": "Optional status message"
}

Pagination Pattern

{
  "success": true,
  "data": [],
  "pagination": {
    "total": 150,
    "per_page": 20,
    "current_page": 1,
    "last_page": 8
  }
}

7) Quick Start (XAMPP / LAMP)

Step 1: Place Project

  • Windows (XAMPP): C:\xampp\htdocs\dooro\
  • Linux (LAMP): /var/www/html/dooro/

Step 2: Environment Setup

cp .env.example .env

Update database and app settings in .env.

Step 3: Database Setup

mysql -u root -p < database/migrations/001_create_schema.sql
mysql -u root -p KeydUkun < database/seeds/001_seed_data.sql

Step 4: Enable Rewrite

  • Ensure Apache mod_rewrite is enabled.
  • Ensure AllowOverride All is enabled for project directory.

Step 5: Access URLs

URL Purpose
http://localhost/dooro/ Main App
http://localhost/dooro/views/auth/login.php Login
http://localhost/dooro/api/v1/ API Base

Default Credentials

Role Email Password
Admin admin@KeydUkun.com password
Manager manager@KeydUkun.com password
Accountant accountant@KeydUkun.com password
Worker worker@KeydUkun.com password

Security note: change all default passwords immediately.

8) Project Structure

dooro/
|-- api/
|   |-- config/
|   |-- controllers/
|   |-- helpers/
|   |-- middleware/
|   `-- index.php
|-- database/
|   |-- migrations/
|   `-- seeds/
|-- includes/partials/
|-- public/assets/
|-- views/
|-- uploads/
|-- logs/
|-- .env.example
|-- .htaccess
`-- index.php

9) Data Model (Core Tables)

users, roles, permissions, role_permissions
auth_tokens, login_logs
suppliers, egg_batches
incubators, incubation_sessions, incubation_logs
hatch_records, chick_batches, cages
mortality_logs, feeding_schedules
inventory_categories, inventory_items, stock_movements
accounts, incomes, expenses, account_transactions
income_categories, expense_categories
departments, employees
payroll_periods, payroll_items, advance_payments
notifications, settings

10) Production Deployment (Linux)

  1. Install Apache, PHP, MySQL.
  2. Enable rewrite module.
  3. Create database and credentials.
  4. Run migrations and seeders.
  5. Configure .env with production values.
  6. Restrict file permissions on uploads/ and logs/.
  7. Enforce HTTPS and strong JWT secret.

11) Operations Checklist

  • Disable debug mode in production.
  • Change seeded passwords and secret keys.
  • Configure SMTP and alert channels.
  • Schedule automated DB backups.
  • Verify role permissions per user group.
  • Validate CORS and API exposure rules.

12) Product Roadmap

  • Multi-language (Somali + English)
  • Mobile client integration
  • AI hatch-rate prediction
  • QR/barcode batch tracking
  • WhatsApp/SMS notifications
  • PDF/Excel exports
  • Cron automation for stage transitions

13) Version

Built for KeydUkun Poultry Farm.
Version 1.0.0 (April 2026)

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages