---
description: "LendCore Laravel loan management system: dual-role authentication, tier-based loans, decimal money handling, inline route patterns. Use when working on loan management features, admin/user portals, or API development."
---

# LendCore Project Instructions

## Build & Test Commands
- `composer dev`: Start full dev environment (PHP server + queue + logs + Vite)
- `composer test`: Run PHPUnit test suite
- `npm run dev`: Frontend watch mode with live reload
- `npm run build`: Production asset build
- `composer setup`: One-time project initialization

## Architecture Overview
- **Dual-Role Authentication**: Single User model with role column; AdminMiddleware/UserMiddleware enforce access
- **Loan Hierarchy**: Tier → Loan → Repayment → Fine (all money fields use decimal:2 casting)
- **Settings System**: Database-driven configuration via Setting model
- **UI Stack**: Blade templates + Tailwind CSS v4 + Vite bundler
- **API**: Sanctum for mobile authentication (minimal endpoints currently)

## Key Conventions
- **Inline Route Handlers**: Logic in `routes/web.php` closures (temporary; will refactor to controllers)
- **Money Arithmetic**: Always use decimal casting to prevent floating-point errors
- **Role Checks**: Middleware-based instead of Gates/Policies
- **Database-First**: Migrations define schema; use seeders for test data

## Common Pitfalls
- Ensure XAMPP MySQL is running before migrations
- Update SESSION_DOMAIN in .env for production (currently set to ngrok)
- Vite port 5173 may conflict; kill Node processes if needed
- Queue uses database driver; switch to sync for dev testing

## Related Resources
- [Project README](README.md) for setup instructions
- [.github/agents/lendcore-implementer.agent.md](.github/agents/lendcore-implementer.agent.md) for phased implementation roadmap