Skip to content

Latest commit

 

History

History
390 lines (283 loc) · 8.67 KB

README_PHASES.md

File metadata and controls

390 lines (283 loc) · 8.67 KB

🎯 CHERRY - PHÁT TRIỂN THEO 4 GIAI ĐOẠN

📋 Tổng quan dự án

Cherry là hệ thống đặt đồ ăn nhanh được phát triển theo kiến trúc Microservices với .NET 8, được chia thành 4 giai đoạn phát triển để quản lý tốt hơn quá trình phát triển, kiểm thử và triển khai.


📊 4 GIAI ĐOẠN PHÁT TRIỂN

🟢 Phase 1: Product Management

Mục tiêu: Xây dựng API quản lý sản phẩm cơ bản

Services:

  • ProductAPI
  • SQL Server Database

Timeline: 1-2 tuần Difficulty: ⭐⭐

Deliverables:

  • CRUD API cho sản phẩm
  • Database với Products table
  • Swagger documentation
  • Unit & Integration tests

📖 Chi tiết Phase 1


🟡 Phase 2: Shopping Cart & Coupons

Mục tiêu: Thêm giỏ hàng và hệ thống mã giảm giá

Services:

  • ProductAPI (từ Phase 1)
  • ShoppingCartAPI
  • CouponAPI
  • SQL Server Database

Timeline: 2-3 tuần Difficulty: ⭐⭐⭐

Deliverables:

  • Cart management API
  • Coupon system
  • Service integration tests
  • Workflow testing

📖 Chi tiết Phase 2


🟠 Phase 3: Authentication & Orders

Mục tiêu: Xác thực người dùng và xử lý đơn hàng

Services:

  • All Phase 2 services
  • AuthAPI (JWT)
  • OrderAPI
  • SQL Server Database

Timeline: 3-4 tuần Difficulty: ⭐⭐⭐⭐

Deliverables:

  • JWT authentication
  • Role-based authorization
  • Order processing
  • Security tests
  • E2E workflow tests

📖 Chi tiết Phase 3


🔴 Phase 4: Complete System

Mục tiêu: Hoàn thiện hệ thống với Frontend, Gateway, Email, Rewards

Services:

  • All Phase 3 services
  • EmailAPI
  • RewardAPI
  • API Gateway (Ocelot)
  • Cherry.Web (Frontend)

Timeline: 4-5 tuần Difficulty: ⭐⭐⭐⭐⭐

Deliverables:

  • Complete web application
  • API Gateway
  • Email notifications
  • Reward points system
  • E2E tests
  • Production deployment

📖 Chi tiết Phase 4


🚀 QUICK START

Cài đặt môi trường

Prerequisites:

  • Docker & Docker Compose
  • .NET 8 SDK (cho development)
  • Git

Chạy một phase

# Phase 1
./scripts/run-phase.sh 1

# Phase 2
./scripts/run-phase.sh 2

# Phase 3
./scripts/run-phase.sh 3

# Phase 4 (Complete system)
./scripts/run-phase.sh 4

Build một phase

./scripts/build-phase.sh <phase_number> <version>

# Ví dụ:
./scripts/build-phase.sh 1 v1.0

Chạy tests

./scripts/run-tests.sh <phase_number> [test_type]

# Ví dụ:
./scripts/run-tests.sh 1 unit
./scripts/run-tests.sh 2 all

Dừng một phase

./scripts/stop-phase.sh <phase_number>

📁 CẤU TRÚC DỰ ÁN

FastFoodOrder/
├── Cherry.Services.AuthAPI/          # Phase 3
├── Cherry.Services.ProductAPI/       # Phase 1
├── Cherry.Services.CouponAPI/        # Phase 2
├── Cherry.Services.ShoppingCartAPI/  # Phase 2
├── Cherry.Services.OrderAPI/         # Phase 3
├── Cherry.Services.EmailAPI/         # Phase 4
├── Cherry.Services.RewardAPI/        # Phase 4
├── Cherry.GatewaySolution/           # Phase 4
├── Cherry.Web/                       # Phase 4
├── docker/
│   └── phases/
│       ├── docker-compose.phase1.yml
│       ├── docker-compose.phase2.yml
│       ├── docker-compose.phase3.yml
│       └── docker-compose.phase4.yml
├── scripts/
│   ├── build-phase.sh
│   ├── run-phase.sh
│   ├── stop-phase.sh
│   ├── run-tests.sh
│   └── deploy-phase.sh
├── .github/workflows/
│   ├── phase1-ci.yml
│   ├── phase2-ci.yml
│   ├── phase3-ci.yml
│   └── phase4-ci.yml
└── docs/
    ├── PHASE_DEVELOPMENT_GUIDE.md
    └── phases/
        ├── phase1/README.md
        ├── phase2/README.md
        ├── phase3/README.md
        └── phase4/README.md

🧪 TESTING STRATEGY

Test Coverage Targets

Phase Unit Tests Integration Tests E2E Tests Coverage
Phase 1 ✅ ✅ - ≥ 70%
Phase 2 ✅ ✅ - ≥ 75%
Phase 3 ✅ ✅ ✅ ≥ 80%
Phase 4 ✅ ✅ ✅ ≥ 80%

Test Types

  1. Unit Tests: Service logic, business rules
  2. Integration Tests: API endpoints, database
  3. E2E Tests: Complete user workflows
  4. Security Tests: Authentication, authorization, SQL injection, XSS
  5. Performance Tests: Load testing, response time

🐳 DOCKER IMAGES

Phase 1

  • cherry-productapi:v1.0-phase1

Phase 2

  • cherry-productapi:v2.0-phase2
  • cherry-couponapi:v2.0-phase2
  • cherry-shoppingcartapi:v2.0-phase2

Phase 3

  • cherry-authapi:v3.0-phase3
  • cherry-orderapi:v3.0-phase3
  • (+ all Phase 2 services)

Phase 4

  • cherry-gateway:v4.0-phase4
  • cherry-web:v4.0-phase4
  • cherry-emailapi:v4.0-phase4
  • cherry-rewardapi:v4.0-phase4
  • (+ all Phase 3 services)

🌿 GIT WORKFLOW

Branches

  • main - Production branch
  • phase1-product-management - Phase 1 development
  • phase2-cart-coupons - Phase 2 development
  • phase3-auth-orders - Phase 3 development
  • phase4-complete-system - Phase 4 development

Tags

  • v1.0-phase1, v1.1-phase1 - Phase 1 releases
  • v2.0-phase2, v2.1-phase2 - Phase 2 releases
  • v3.0-phase3, v3.1-phase3 - Phase 3 releases
  • v4.0-phase4, v4.1-phase4 - Phase 4 releases

🤖 CI/CD

GitHub Actions Workflows

Mỗi phase có workflow riêng:

  1. phase1-ci.yml: Build & test ProductAPI
  2. phase2-ci.yml: Build & test all Phase 2 services
  3. phase3-ci.yml: Build, test & security scan Phase 3
  4. phase4-ci.yml: Build, test & deploy complete system

Workflow Steps

  1. Checkout code
  2. Setup .NET 8
  3. Restore dependencies
  4. Build projects
  5. Run tests
  6. Build Docker images
  7. Push to Docker Hub (on tag)
  8. Deploy to production (Phase 4 only)

📊 SERVICE ENDPOINTS

Phase 1

  • ProductAPI: http://localhost:5002

Phase 2

  • ProductAPI: http://localhost:5002
  • CouponAPI: http://localhost:5003
  • ShoppingCartAPI: http://localhost:5004

Phase 3

  • AuthAPI: http://localhost:5001
  • OrderAPI: http://localhost:5005
  • (+ all Phase 2 services)

Phase 4

  • Web Application: http://localhost:5008
  • API Gateway: http://localhost:5000
  • EmailAPI: http://localhost:5006
  • RewardAPI: http://localhost:5007
  • (+ all Phase 3 services)

📚 TÀI LIỆU


🎯 LEARNING OBJECTIVES

Sau khi hoàn thành 4 phases, bạn sẽ học được:

  1. ✅ Microservices Architecture: Thiết kế và triển khai microservices
  2. ✅ Docker & Containerization: Build và deploy containers
  3. ✅ API Development: RESTful API với .NET 8
  4. ✅ Authentication & Authorization: JWT, Role-based access
  5. ✅ Testing: Unit, Integration, E2E, Security testing
  6. ✅ CI/CD: Automated build, test, deployment
  7. ✅ Database Design: SQL Server, Entity Framework Core
  8. ✅ API Gateway: Ocelot routing
  9. ✅ Frontend Development: ASP.NET MVC/Razor Pages
  10. ✅ DevOps: Monitoring, logging, deployment

🆘 TROUBLESHOOTING

Port đã được sử dụng

lsof -i :5002
./scripts/stop-phase.sh <phase_number>

Database connection failed

docker-compose -f docker/phases/docker-compose.phase1.yml restart cherry-db

Build failed

docker builder prune
docker-compose -f docker/phases/docker-compose.phase1.yml build --no-cache

👥 CONTRIBUTORS

  • Phát triển: [Your Name]
  • Giảng viên hướng dẫn: [Instructor Name]

📄 LICENSE

This project is for educational purposes.


🎉 DEMO

🎬 Demo Video


Happy Coding! 🚀


📞 Support

Nếu gặp vấn đề:

  1. Kiểm tra logs: docker-compose logs
  2. Xem documentation trong docs/
  3. Tạo issue trên GitHub
  4. Liên hệ giảng viên

Project Timeline: 10-14 tuần (2.5-3.5 tháng)

Last Updated: 2025-10-07