stagingbackend / QUICKSTART.md
Antaram's picture
Upload 18 files
9eab1a6 verified
# 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