Spaces:
Running
Running
Quick Start Guide
β Backend is Ready!
Your complete Express.js backend with PostgreSQL is now running on http://localhost:4000
π What's Been Done
β Database Setup
- Created 7 tables with proper relationships
- Added indexes for performance
- Seeded with sample data
β API Endpoints Working
- Parties API:
/api/parties - Mirchi Types API:
/api/mirchi-types - Lots API:
/api/lots - Transactions API:
/api/transactions
- Parties API:
β Sample Data Loaded
- 5 Parties (Ramesh Traders, Suresh & Co, etc.)
- 5 Mirchi Types (Teja, Byadgi, Guntur Sannam, etc.)
- 3 Active Lots with stock
- 1 Sample Transaction
π§ Available Commands
cd backend
# Start server (currently running)
npm start
# Development mode with auto-reload
npm run dev
# Database management
npm run migrate # Create tables
npm run seed # Add sample data
npm run reset # Drop all tables (β οΈ use with caution)
π‘ Test the API
Health Check:
curl http://localhost:4000/health
Get All Parties:
curl http://localhost:4000/api/parties
Get All Mirchi Types:
curl http://localhost:4000/api/mirchi-types
Get All Transactions:
curl http://localhost:4000/api/transactions
π Connect Frontend
Update your frontend's db.ts file:
- The API_BASE is already set to
http://localhost:4000/api - All endpoints are ready to use
- No changes needed in frontend code!
π Database Schema
Tables:
parties- Customer/supplier managementmirchi_types- Chili pepper varietieslots- Inventory with stock trackingtransactions- Purchase/sales billstransaction_items- Line itemsexpenses- Transaction expensespayments- Payment records
π― Next Steps
- Keep the backend server running
- Start your frontend:
cd frontend && npm run dev - Test the complete application!
π‘ Features
- β Full CRUD operations for all entities
- β Automatic stock management (lots)
- β Party balance tracking
- β Payment tracking with multiple modes
- β Support for returns (purchase/sales)
- β Transaction filtering by party, type, etc.
- β Proper error handling and validation
π Troubleshooting
Server not starting?
- Check if port 4000 is available
- Verify PostgreSQL connection in
.env
Database errors?
- Run
npm run resetthennpm run migrateandnpm run seed
API not responding?
- Check server logs in terminal
- Verify server is running on port 4000