A comprehensive full-stack application for managing dairy operations, farmers, milk collections, payments, and expenses.
Dairy Management Sys/
├── backend/ # Backend API (Node.js/Express/Prisma/PostgreSQL)
│ ├── src/
│ │ ├── api/ # API routes and controllers
│ │ ├── middleware/# Authentication and other middleware
│ │ ├── utils/ # Utility functions (PDF generation, etc.)
│ │ └── server.js # Main server file
│ ├── prisma/ # Database schema and migrations
│ └── package.json
├── frontend/ # Frontend application (React/Next.js/etc.)
├── .gitignore # Root-level gitignore
└── README.md # This file
- User Authentication: JWT-based authentication with role-based access control (Admin/Farmer)
- Milk Collection Management: Record and track daily milk collections with quality parameters
- Payment Processing: Automated billing generation and payment tracking
- Expense Management: Track operational expenses with categorization
- PDF Reports: Generate detailed farmer statements and reports
- RESTful API: Well-structured API endpoints with proper validation and error handling
- Runtime: Node.js
- Framework: Express.js
- Database: PostgreSQL
- ORM: Prisma
- Authentication: JWT (jsonwebtoken) + bcryptjs
- PDF Generation: PDFKit
- Security: Helmet, CORS, Rate Limiting
- Framework: [To be implemented - React/Next.js/Vue.js/etc.]
- Styling: [To be determined]
- State Management: [To be determined]
- Node.js (v16 or higher)
- PostgreSQL database
- npm or yarn package manager
-
Navigate to backend directory
cd "Dairy Management Sys/backend"
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Edit
.envwith your configuration:NODE_ENV=development PORT=3000 DATABASE_URL="postgresql://username:password@localhost:5432/dairy_management?schema=public" JWT_SECRET="your-super-secret-jwt-key" JWT_EXPIRES_IN="7d" BCRYPT_ROUNDS=12
-
Set up the database
npm run db:generate npm run db:push
-
Start the backend server
npm run dev
The backend API will be available at http://localhost:3000
[Instructions to be added when frontend is implemented]
The backend provides a comprehensive REST API. Key endpoints include:
POST /api/v1/auth/initialize-admin- Create first admin user (one-time)POST /api/v1/auth/register- Register new farmerPOST /api/v1/auth/login- User login
POST /api/v1/milk-collections- Record milk collection (Admin only)GET /api/v1/milk-collections- Get all collections (Admin only)
POST /api/v1/billing/generate- Generate billing from unbilled collections (Admin only)GET /api/v1/payments- Get all payments (Admin only)
GET /api/v1/reports/farmer-statement/:userId- Generate PDF farmer statement
For complete API documentation, see the backend README.
cd backend
npm run dev # Start development server with nodemon
npm run db:studio # Open Prisma Studio for database management
npm run db:migrate # Create and apply database migrations[Instructions to be added when frontend is implemented]
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email support@smartdairy.com or create an issue in this repository.