AI assistant for developing and managing Ledger, a full-stack shop management system for Indian small businesses. Handles customer management, transactions (khata), invoicing, and financial reporting built with React + Express + PostgreSQL.
An AI assistant specialized in developing and maintaining Ledger, a full-stack shop management system designed for Indian small businesses.
This skill provides expert guidance for working with the Ledger application, which handles:
The tech stack includes React 18 (frontend), Express.js (backend), PostgreSQL (database), and Material-UI for UI components.
**Tech Stack:**
**Project Structure:**
```
ledger/
├── client/src/ # React frontend
│ ├── components/ # Reusable UI components
│ ├── pages/ # Route pages
│ ├── context/ # Auth context
│ ├── hooks/ # Custom hooks
│ └── helpers/ # Utilities
├── server/ # Express backend
│ ├── controllers/ # Route handlers
│ ├── routes/ # API definitions
│ ├── models/ # DB models
│ └── middleware/ # Express middleware
└── docker-compose.yml
```
1. **Identify the layer** (frontend/backend/database) and locate relevant files:
- Frontend components: `client/src/components/` or `client/src/pages/`
- API endpoints: `server/routes/` and `server/controllers/`
- Database: `server/models/`
2. **Follow existing patterns:**
- Frontend: Use functional components with hooks, MUI components for UI
- Backend: Controllers handle logic, always validate inputs with express-validator
- Database: Use parameterized queries (prevent SQL injection)
3. **Handle errors and loading states:**
- Frontend: Always show loading spinners and error messages
- Backend: Return consistent JSON format:
```json
{ "success": true, "data": {...} }
{ "success": false, "message": "Error" }
```
4. **Respect authentication:**
- Protected routes require JWT middleware
- Token stored in cookies
- Check `middleware/auth.js` for auth logic
**New API Endpoint:**
1. Create route file in `server/routes/`
2. Create controller in `server/controllers/`
3. Add validation middleware (express-validator)
4. Register route in `server/server.js`
**New Frontend Page:**
1. Create component in `client/src/pages/`
2. Add route in `client/src/App.js`
3. Update navigation components if needed
**Database Schema Change:**
1. Update SQL in `server/models/makeSQLTables.js`
2. Run `npm run db:setup` to initialize
3. Update relevant model files
1. **Check environment variables:**
- Client: `REACT_APP_API_URL` in `client/.env`
- Server: `DATABASE_URL`, `JWT_SECRET`, `PORT` in `server/.env`
2. **Review API structure:**
- All routes prefixed with `/api`
- Authentication: `/api/auth/*`
- Customers: `/api/customers/*`
- Transactions: `/api/transactions/*`
- Dashboard: `/api/dashboard/stats`
3. **Check logs:**
- Docker: `docker-compose logs -f`
- Server: Console logs in terminal
- Client: Browser console
**Client:**
```bash
cd client
npm start # Dev server (port 3000)
npm run build # Production build
npm test # Run tests
npm run lint:fix # Fix linting
```
**Server:**
```bash
cd server
npm run dev # Dev with nodemon (port 5000)
npm test # Jest tests
npm run db:setup # Initialize database
```
**Docker:**
```bash
docker-compose up -d # Start services
docker-compose down # Stop services
```
**Authentication:**
**Customers:**
**Transactions:**
**Dashboard:**
**User asks:** "Add a new customer search feature"
1. Read `client/src/pages/Customers.js` to understand current implementation
2. Add search input using MUI TextField component
3. Implement filtering logic with useState hook
4. Consider adding debouncing for performance
5. Update backend if server-side search is needed
**User asks:** "Fix transaction deletion bug"
1. Check `server/controllers/transactionController.js` for delete logic
2. Verify route in `server/routes/transactions.js`
3. Check authentication middleware is applied
4. Test with Postman or frontend
5. Review error handling and response format
**User asks:** "Add export to PDF feature"
1. Read existing `/api/transactions/export` endpoint
2. Install PDF library if needed (e.g., pdfkit)
3. Create PDF generation logic in controller
4. Add frontend button to trigger export
5. Handle file download in browser
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/ledger-shop-management/raw