Cursor Rules for Pharmacy POS System
🚨 CRITICAL DATABASE RULES
NEVER MODIFY THE MYSQL DATABASE
- Do NOT create, alter, or drop any tables
- Do NOT modify existing table structures
- Do NOT run database migration scripts
- The database is already properly set up and working
- Only use the existing database connection through
backend/config/database.js
📋 EXISTING DATABASE SCHEMA
Use ONLY these exact table structures:
1. medicines
drug_id, drug_name, dosage, form, manufacturer, base_price, category_id, image_path
2. inventory
inventory_id, batch_id, drug_id, stock_level, expiry_date, reorder_level, date_received
3. orders
order_id, account_id, order_date, discount, total_amount
4. order_details
order_detail_id, inventory_id, quantity, order_id, unit_price
5. pharmacists
pharmacist_id, first_name, last_name, phone_number, email, license_number
6. payments
order_id, payment_type_id, amount_paid, change_amount
7. payment_types
payment_type_id, payment_type
8. categories
category_id, category_name
9. accounts
account_id, username, password, pharmacist_id, is_active, role, created_at, updated_at, last_login
🔧 DEVELOPMENT GUIDELINES
Database Connection
- Use
backend/config/database.js for all database connections
- Never create new database connection files
- Use the existing connection pool
Code Style
- Follow existing project structure in
backend/ folder
- Use consistent naming conventions that match the database schema
- Maintain existing API route structure in
backend/routes/
API Development
- Build APIs that work with the existing table structure
- Use proper SQL queries that match the exact column names
- Handle database relationships according to the existing schema
File Structure
- Keep backend code in
backend/ directory
- Use existing middleware from
backend/middleware/
- Store uploads in
backend/uploads/
- Maintain logs in
backend/logs/
⚠️ WHAT NOT TO DO
- Never create database setup/migration scripts
- Never modify package.json to add database setup commands
- Never suggest database schema changes
- Never create alternative table structures
- Never ignore the existing column names
✅ WHAT TO DO
- Always refer to the exact table and column names listed above
- Use the existing database connection configuration
- Write SQL queries that match the existing schema
- Respect the current relationships between tables
- Follow the established project structure
🎯 PROJECT CONTEXT
This is a Pharmacy Management System with:
- Inventory management for medicines
- Order processing and payment handling
- User account management with roles
- Pharmacist information tracking
- Category-based medicine organization
The database is already working properly and should remain unchanged.