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 | |
| 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 | |