A modern sweet shop management system for browsing, purchasing, and managing Indian sweets inventory.
For Customers:
- Browse sweets with search & filters (name, category, price)
- Real-time stock availability
- Purchase sweets with instant quantity updates
For Admins:
- Add, edit, and delete sweets
- Restock inventory
- Manage complete product catalog
Security:
- JWT authentication with HTTP-only cookies
- Role-based access (USER/ADMIN)
- Bcrypt password hashing
Backend: Next.js 16 API Routes, MongoDB, TypeScript
Frontend: React 19, Tailwind CSS v4, shadcn/ui
Testing: Jest with comprehensive test coverage
- Node.js 18+
- MongoDB Atlas account (or local MongoDB)
- Clone and install:
git clone https://github.com/Anomasingh/MishtiFlow.git
cd MishtiFlow
npm install- Environment variables (
.env.local):
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key- Seed database:
npx tsx scripts/seed-database.tsDefault credentials:
- Admin:
admin@mishtiflow.com/admin123 - User:
user@mishtiflow.com/user123
- Run development server:
npm run devVisit http://localhost:3000
npm test # Run tests
npm run test:watch # Watch mode``` ├── app/ │ ├── api/ # API routes │ │ ├── auth/ # Authentication endpoints │ │ └── sweets/ # Sweet management endpoints │ ├── admin/ # Admin panel page │ ├── dashboard/ # Main dashboard │ ├── login/ # Login page │ └── register/ # Registration page ├── components/ │ ├── ui/ # shadcn/ui components │ ├── navbar.tsx # Navigation bar │ ├── sweet-card.tsx # Sweet display card │ ├── search-filter-bar.tsx │ └── [admin components] ├── lib/ │ ├── auth.ts # JWT utilities │ ├── db.ts # Database utilities │ └── validators.ts # Zod schemas ├── tests/ # Test files ├── scripts/ # Database scripts └── prisma/ # Prisma schema ```
POST /api/auth/register- Register new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout userGET /api/auth/me- Get current user
GET /api/sweets- List all sweets (with filters)POST /api/sweets- Create sweet (ADMIN)GET /api/sweets/:id- Get single sweetPUT /api/sweets/:id- Update sweet (ADMIN)DELETE /api/sweets/:id- Delete sweet (ADMIN)POST /api/sweets/:id/purchase- Purchase sweetPOST /api/sweets/:id/restock- Restock sweet (ADMIN)
This project was built with assistance from v0 by Vercel, an AI-powered development assistant. Here's how AI contributed to the development process:
-
Boilerplate Code Generation: AI helped generate initial project structure, component scaffolding, and configuration files, significantly reducing setup time.
-
UI Design: AI generated design inspiration and helped implement a cohesive color palette inspired by Indian sweets (saffron, rose, pistachio, cardamom) with proper Tailwind CSS theming.
-
Test Writing: AI assisted in writing comprehensive test cases following TDD principles, covering authentication, validation, CRUD operations, and edge cases.
-
API Route Implementation: AI helped structure API routes with proper error handling, validation, and response formatting.
-
Type Safety: AI helped ensure TypeScript types were properly defined throughout the application.
While AI provided a strong foundation, human engineering judgment was crucial for:
- Architecture Decisions: Choosing between Prisma ORM vs raw SQL queries (opted for raw SQL for better control)
- Security Implementation: Ensuring proper JWT handling, HTTP-only cookies, and bcrypt configuration
- Business Logic: Atomic stock updates, purchase validation, and authorization rules
- Database Design: Schema structure, relationships, and query optimization
- Error Handling: Context-specific error messages and proper HTTP status codes
- Testing Strategy: Deciding what to test and ensuring meaningful coverage
AI significantly improved productivity by:
- Reducing time spent on repetitive code patterns
- Providing instant syntax and API reference
- Generating test cases that might have been overlooked
- Suggesting accessibility improvements and best practices
However, AI did not replace the need for:
- Understanding business requirements
- Making architectural trade-offs
- Debugging complex issues
- Code review and refactoring
- Security auditing
The combination of AI assistance and human expertise resulted in a production-ready application built faster without compromising quality or security.
- Create a PostgreSQL database on your hosting platform
- Set environment variables:
DATABASE_URLJWT_SECRET
- Deploy the Next.js application
- Run database scripts after deployment
- Connect your GitHub repository to Vercel
- Set environment variables in Vercel dashboard
- Deploy automatically on push to main branch
- Test-Driven Development: Comprehensive test coverage for critical paths
- SOLID Principles: Separation of concerns, single responsibility
- Security First: Password hashing, JWT tokens, authorization checks
- Type Safety: Full TypeScript coverage
- Clean Code: Meaningful names, proper comments, modular structure
- Atomic Operations: Database transactions for inventory updates
- Error Handling: Centralized error handling with clear messages
- Validation: Input validation at API and UI levels
- Responsive Design: Mobile-first approach with Tailwind CSS
MIT
For questions or support, please open an issue on GitHub.