Spaces:
Running
Running
File size: 2,685 Bytes
9eab1a6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | # Quick Start Guide
## β
Backend is Ready!
Your complete Express.js backend with PostgreSQL is now running on **http://localhost:4000**
## π What's Been Done
1. β
**Database Setup**
- Created 7 tables with proper relationships
- Added indexes for performance
- Seeded with sample data
2. β
**API Endpoints Working**
- Parties API: `/api/parties`
- Mirchi Types API: `/api/mirchi-types`
- Lots API: `/api/lots`
- Transactions API: `/api/transactions`
3. β
**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
```bash
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:**
```bash
curl http://localhost:4000/health
```
**Get All Parties:**
```bash
curl http://localhost:4000/api/parties
```
**Get All Mirchi Types:**
```bash
curl http://localhost:4000/api/mirchi-types
```
**Get All Transactions:**
```bash
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:**
1. `parties` - Customer/supplier management
2. `mirchi_types` - Chili pepper varieties
3. `lots` - Inventory with stock tracking
4. `transactions` - Purchase/sales bills
5. `transaction_items` - Line items
6. `expenses` - Transaction expenses
7. `payments` - Payment records
## π― Next Steps
1. Keep the backend server running
2. Start your frontend: `cd frontend && npm run dev`
3. 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 reset` then `npm run migrate` and `npm run seed`
**API not responding?**
- Check server logs in terminal
- Verify server is running on port 4000
|