A full-stack Sweet Shop Management System built with modern technologies following Test-Driven Development (TDD) practices.
| Service | URL |
|---|---|
| Frontend | https://sweet-shop-ten.vercel.app |
| Backend API | https://sweet-shop-api-1fxc.onrender.com |
Note: The backend is hosted on Render's free tier, so it may take ~30 seconds to wake up on first request.
- Live Demo
- Features
- Tech Stack
- Project Structure
- Getting Started
- API Documentation
- Testing
- My AI Usage
- Screenshots
- π User registration and login with JWT authentication
- π Browse all available sweets
- π Search and filter sweets by name, category, and price range
- π° Purchase sweets (quantity decreases on purchase)
- π± Responsive design for all devices
- β Add new sweets to inventory
- βοΈ Edit existing sweet details
- ποΈ Delete sweets from catalog
- π¦ Restock sweets (increase quantity)
- π Admin-only access controls
- Runtime: Node.js
- Framework: Express.js
- Language: TypeScript
- Database: SQLite (using better-sqlite3)
- Authentication: JWT (jsonwebtoken)
- Password Hashing: bcryptjs
- Validation: express-validator
- Testing: Jest + Supertest
- Framework: React 18
- Language: TypeScript
- Build Tool: Vite
- Routing: React Router DOM
- HTTP Client: Axios
- Styling: CSS (custom)
incubytevs/
βββ backend/
β βββ src/
β β βββ config/
β β β βββ database.ts # SQLite database configuration
β β βββ middleware/
β β β βββ auth.middleware.ts # JWT authentication middleware
β β βββ models/
β β β βββ user.model.ts # User model and operations
β β β βββ sweet.model.ts # Sweet model and operations
β β βββ routes/
β β β βββ auth.routes.ts # Auth endpoints
β β β βββ sweets.routes.ts # Sweets CRUD + inventory endpoints
β β βββ tests/
β β β βββ setup.ts # Test configuration
β β β βββ auth.test.ts # Auth endpoint tests
β β β βββ sweets.test.ts # Sweets CRUD tests
β β β βββ inventory.test.ts # Purchase/restock tests
β β βββ utils/
β β β βββ jwt.ts # JWT utilities
β β βββ app.ts # Express app configuration
β β βββ index.ts # Server entry point
β βββ data/ # SQLite database files
β βββ coverage/ # Test coverage reports
β βββ package.json
β βββ tsconfig.json
β
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Navbar.tsx # Navigation component
β β β βββ SweetCard.tsx # Sweet display card
β β β βββ SearchFilter.tsx # Search and filter component
β β βββ context/
β β β βββ AuthContext.tsx # Authentication context
β β βββ pages/
β β β βββ LoginPage.tsx # Login page
β β β βββ RegisterPage.tsx # Registration page
β β β βββ DashboardPage.tsx # Main sweet listing
β β β βββ AdminPage.tsx # Admin management panel
β β βββ services/
β β β βββ api.ts # Axios configuration
β β β βββ sweets.ts # Sweets API service
β β βββ types/
β β β βββ index.ts # TypeScript type definitions
β β βββ config/
β β βββ api.ts # API configuration
β βββ package.json
β βββ vite.config.ts
β
βββ README.md
- Node.js (v18 or higher)
- npm (v9 or higher)
-
Navigate to the backend directory:
cd backend -
Install dependencies:
npm install
-
Create environment file (optional - uses defaults):
# .env file PORT=3001 NODE_ENV=development JWT_SECRET=your-super-secret-jwt-key DATABASE_PATH=./data/sweetshop.db -
Run tests to verify setup:
npm test -
Start the development server:
npm run dev
The backend will be running at http://localhost:3001
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
The frontend will be running at http://localhost:5173
- Open two terminal windows
- In terminal 1:
cd backend && npm run dev - In terminal 2:
cd frontend && npm run dev
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/register |
Register a new user | No |
| POST | /api/auth/login |
Login and get token | No |
{
"email": "user@example.com",
"password": "password123",
"name": "John Doe",
"role": "user" // or "admin"
}{
"email": "user@example.com",
"password": "password123"
}| Method | Endpoint | Description | Admin Only |
|---|---|---|---|
| GET | /api/sweets |
Get all sweets | No |
| GET | /api/sweets/search |
Search sweets | No |
| POST | /api/sweets |
Create a new sweet | No |
| PUT | /api/sweets/:id |
Update a sweet | No |
| DELETE | /api/sweets/:id |
Delete a sweet | Yes |
{
"id": "uuid",
"name": "Chocolate Cake",
"category": "Cakes",
"price": 25.99,
"quantity": 10,
"description": "Delicious chocolate cake",
"image_url": "https://example.com/cake.jpg"
}name- Search by name (partial match)category- Filter by categoryminPrice- Minimum pricemaxPrice- Maximum price
| Method | Endpoint | Description | Admin Only |
|---|---|---|---|
| POST | /api/sweets/:id/purchase |
Purchase a sweet | No |
| POST | /api/sweets/:id/restock |
Restock a sweet | Yes |
{
"quantity": 2 // optional, defaults to 1
}{
"quantity": 50 // required
}cd backend
npm testnpm run test:watchnpm run test:coverage- Total Tests: 47
- All Passing: β
- Coverage: ~86%
Test Suites: 3 passed, 3 total
Tests: 47 passed, 47 total
Snapshots: 0 total
- Auth Tests (12): Registration and login validation
- Sweets Tests (20): CRUD operations and search
- Inventory Tests (15): Purchase and restock operations
- GitHub Copilot (Claude Opus 4.5): Primary AI assistant for code generation and development
-
Project Architecture & Planning
- I used AI to help design the project structure and determine the best technology stack for the requirements
- The AI helped outline the TDD approach and test categories
-
Boilerplate Generation
- Initial Express.js setup with TypeScript configuration
- Database schema design and SQLite integration
- JWT authentication middleware structure
- React component scaffolding
-
Test Writing (TDD Red Phase)
- AI helped generate comprehensive test cases following TDD principles
- Tests were written BEFORE implementation to define expected behavior
- Coverage includes edge cases like validation errors, authentication failures, and insufficient stock scenarios
-
Implementation (TDD Green Phase)
- Routes and controllers were implemented to make tests pass
- Model layer with SQLite operations
- Frontend React components with proper TypeScript types
-
Code Review & Refactoring
- AI suggested improvements for code organization
- Helped identify and fix bugs (e.g., the purchase route bug with undefined body)
- TypeScript type safety improvements
Positive Impacts:
- Significantly accelerated boilerplate code generation
- Helped maintain consistency across the codebase
- Provided comprehensive test coverage suggestions
- Reduced time spent on syntax and configuration issues
Learning Experience:
- AI is excellent for repetitive patterns but requires human oversight for edge cases
- The TDD process was enhanced by AI generating test scenarios I might have missed
- AI suggestions needed validation against project requirements
Responsible AI Usage:
- All AI-generated code was reviewed and understood before inclusion
- Business logic and architectural decisions were made by me
- AI was used as a productivity tool, not a replacement for understanding
All commits in this project where AI was used include the co-author trailer:
Co-authored-by: GitHub Copilot <copilot@github.com>
User authentication with email and password
New user registration with admin option
Browse, search, and purchase sweets
For user
For admin
Filter sweets by category, name, and price range
Add new sweets to inventory
Edit existing sweet details
Optimized for all screen sizes
This project is licensed under the ISC License.
Built as part of the Sweet Shop Management System TDD Kata assignment.
Made with β€οΈ and π¬







