A full-stack MERN application for browsing, ordering, and managing Starbucks products with payment integration.
- Docker Desktop installed
.envfile configured (see section below)
# Build and start all services (Frontend, Backend, MongoDB)
docker-compose up --build -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down| Service | URL | Port |
|---|---|---|
| Frontend (Client) | http://localhost | 80 |
| Backend API | http://localhost:3002 | 3002 |
| MongoDB | localhost:27017 | 27017 |
Email: [email protected]
Password: password123
# Install backend dependencies
npm i
# Initialize TypeScript
npx tsc --init
# Install frontend dependencies
cd client
npm i
cd ..Create .env file in root directory:
PORT=3002
DATABASE=mongodb+srv://your-mongodb-uri
DATABASE_LOCAL=mongodb://localhost:27017/starbucks
STRIPE_SECRET_KEY=sk_test_your_key
CLIENT_URL=http://localhost:3000
JWT_SECRET=your-secret-key
JWT_EXPIRES_IN=7d
JWT_COOKIE_EXPIRES_IN=7Terminal 1 - Backend:
npm run dev
# Server runs at http://localhost:3002Terminal 2 - Frontend:
cd client
npm run dev
# Client runs at http://localhost:5173POST /api/v1/auth/register- Register new userPOST /api/v1/auth/login- User loginPOST /api/v1/auth/logout- User logout
GET /api/v1/products- Get all productsGET /api/v1/products/:id- Get product detailsPOST /api/v1/products- Create product (Admin)PATCH /api/v1/products/:id- Update product (Admin)DELETE /api/v1/products/:id- Delete product (Admin)
GET /api/v1/categories- Get all categoriesPOST /api/v1/categories- Create category (Admin)PATCH /api/v1/categories/:id- Update category (Admin)DELETE /api/v1/categories/:id- Delete category (Admin)
GET /api/v1/orders- Get ordersPOST /api/v1/orders- Create orderPATCH /api/v1/orders/:id- Update order status
POST /api/v1/payment/create-checkout- Create Stripe checkout
# Backend
npm run dev # Start dev server with Nodemon
npm run build # Compile TypeScript to JavaScript
npm run start # Start production server
npm run test # Run all tests
npm run seed # Seed database with initial data
# Frontend (in client directory)
npm run dev # Start Vite dev server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLintstarbucks/
├── src/ # Backend source (TypeScript)
│ ├── controller/ # Business logic
│ ├── models/ # MongoDB schemas
│ ├── routes/ # API routes
│ ├── middleware/ # Custom middleware
│ └── utils/ # Utilities & helpers
├── client/ # Frontend (React + Vite)
│ ├── src/
│ │ ├── pages/ # Page components
│ │ ├── components/ # Reusable components
│ │ ├── context/ # React Context
│ │ └── services/ # API service layer
│ └── Dockerfile # Frontend container config
├── docker-compose.yml # Docker orchestration
├── Dockerfile # Backend container config
└── .env # Environment variables
docker-compose ps # See all running containers
docker-compose logs backend # View backend logs
docker-compose logs frontend # View frontend logsdocker-compose down # Stop all containers
docker system prune # Clean up unused images
docker-compose up --build # Rebuild and restartdocker volume rm starbucks_mongo-data
docker-compose up # Will recreate fresh MongoDB| Variable | Description | Example |
|---|---|---|
PORT |
Backend port | 3002 |
DATABASE |
MongoDB Atlas URI | mongodb+srv://... |
DATABASE_LOCAL |
Local MongoDB URI | mongodb://mongo:27017/starbucks |
STRIPE_SECRET_KEY |
Stripe secret key | sk_test_... |
CLIENT_URL |
Frontend URL | http://localhost |
JWT_SECRET |
JWT signing secret | your-secret-key |
JWT_EXPIRES_IN |
Token expiration | 7d |
npm test # Run all tests
npm run test:watch # Run tests in watch modeBackend: Node.js, Express.js, TypeScript, MongoDB, Mongoose, JWT, Stripe
Frontend: React, Vite, TailwindCSS, React Router, Context API
Deployment: Docker, Vercel (Frontend), Render (Backend), MongoDB Atlas
- See
DEPLOY.mdfor cloud deployment instructions - See
client/README.mdfor frontend-specific setup - See
src/models/README.mdfor database schema documentation
ISC
Last Updated: May 4, 2024