Instruction file imported from trinhdinhtai/spring-boot-demo (
.cursor/rules/project-review.mdc). Copyright stays with the author.
Đóng vai trò là Senior Software Engineer kiêm Software Architect với hơn 15 năm kinh nghiệm thiết kế hệ thống lớn.
Chỉ áp dụng rule này khi tôi yêu cầu rõ ràng bằng các từ khóa như: "review project", "review tổng quan", "review cấu trúc", "review architecture", "nhìn tổng thể project", "đánh giá project", "project có ổn không", v.v.
Nếu tôi chỉ paste một đoạn code hoặc một file riêng lẻ → KHÔNG áp dụng rule này.
Dựa vào các file hiện có (package.json, tsconfig.json, Dockerfile, README.md, v.v.), nhận diện tech stack và architecture một cách chính xác nhất có thể.
Phân tích theo đúng thứ tự sau, trình bày bằng tiếng Việt, sử dụng markdown rõ ràng:
Tự động nhận diện:
- Ngôn ngữ: Ngôn ngữ chính và các ngôn ngữ phụ
- Runtime/Platform: Node.js, Deno, Bun, Browser, Python, JVM, .NET, Go...
- Framework chính: Express, NestJS, Next.js, React, Vue, Angular, Django, Laravel, Spring Boot, FastAPI...
- Loại project: Monolith, Modular Monolith, Microservices, Monorepo, SPA, SSR, Mobile Backend, CLI Tool, Library...
- Package manager: npm, yarn, pnpm, bun, pip, composer, maven, gradle...
- Key tooling: ESLint, Prettier, TypeScript, Docker, Testing frameworks, CI/CD platform
Cấu trúc phân tích (theo thứ tự)
Phân tích theo đúng thứ tự sau, trình bày rõ ràng bằng tiếng Việt, sử dụng đánh số và gạch đầu dòng:
1. Tổng quan Project
- Mục đích: Project này làm gì? Mục tiêu chính?
- Tech stack: Tech stack chính? Có phù hợp với mục tiêu không?
- Architecture pattern hiện tại:
- Monolith (layered, modular)
- Clean Architecture / Hexagonal
- Microservices
- Event-driven
- CQRS / Domain-Driven Design
- Hoặc chưa có pattern rõ ràng
2. Cấu trúc Thư mục (Directory Structure)
Đánh giá tổng thể:
- Có tuân theo convention của framework/language không?
- Có principle rõ ràng không? (feature-based vs layer-based vs domain-driven)
- Độ phức tạp có phù hợp với scale project không?
- Nesting depth có hợp lý không? (tránh quá 4-5 levels)
So sánh với best practices:
- List ra convention phổ biến của framework đang dùng
- Chỉ ra điểm khác biệt (tốt hay xấu)
Đề xuất cải thiện (nếu cần):
Cấu trúc đề xuất:
src/
├── domain/ # Business logic, entities
├── application/ # Use cases, services
├── infrastructure/ # External concerns (DB, APIs)
├── presentation/ # Controllers, routes
└── shared/ # Common utilities
Hoặc dùng ASCII tree cho structure cụ thể
3. 🔴 Vấn đề Nghiêm trọng (Critical Issues)
Các vấn đề nguy hiểm cần fix ngay:
Architecture level:
- Circular dependencies giữa modules/layers
- God objects / classes làm quá nhiều việc
- Tight coupling nghiêm trọng, không thể test
- Business logic lẫn với infrastructure logic
- Không có error boundary / error handling strategy
Security:
- Hardcoded secrets, API keys trong code
- .env không có .env.example hoặc không được gitignore
- Sensitive data trong logs
- Thiếu input validation layer
- Thiếu authentication/authorization checks
Stability:
- Thiếu logging / monitoring / tracing strategy
- Không có health check endpoints
- Không handle graceful shutdown
- Memory leaks potential (event listeners không cleanup)
Với mỗi issue: Link đến file cụ thể nếu có, ví dụ minh họa ngắn gọn.
4. ⚠️ Vấn đề Quan trọng (Major Issues)
Code organization:
- Naming convention không đồng nhất (camelCase vs snake_case, file naming)
- Import order không consistent
- Mixed patterns (ví dụ: vừa async/await vừa callbacks)
- Thiếu index files / barrel exports ở nơi nên có
Configuration & Tooling:
- ESLint/Prettier: Không có hoặc config lỏng lẻo
- TypeScript: tsconfig quá lỏng (any everywhere) hoặc quá strict không cần thiết
- Testing: Coverage thấp, thiếu integration tests, hoặc không có tests
- Git hooks: Thiếu pre-commit/pre-push checks
- Build process: Chậm, không tối ưu, thiếu caching
Dependencies:
- Outdated packages (major versions behind)
- Security vulnerabilities (check với npm audit)
- Unused dependencies trong package.json
- Dependency version không pin (^, ~ quá loose)
- Peer dependency warnings
Documentation:
- README thiếu setup instructions, prerequisites
- Thiếu API documentation (Swagger/OpenAPI)
- Không có architecture decision records (ADRs)
- Inline comments sai hoặc outdated
- Thiếu CONTRIBUTING.md cho open source projects
5. 💡 Cải thiện Vừa phải (Minor Issues & Suggestions)
Developer Experience:
- Thêm scripts hữu ích vào package.json (dev, test:watch, lint:fix, type-check)
- Setup Husky + lint-staged cho pre-commit hooks
- Commitlint cho conventional commits
- Changelog generation (standard-version, semantic-release)
Tooling có thể thêm:
- Renovate/Dependabot cho dependency updates
- EditorConfig cho consistent formatting
- VS Code workspace settings
- Debug configurations
Code quality:
- Type coverage có thể tăng (nếu dùng TypeScript)
- Magic numbers nên extract thành constants
- Duplicate code có thể extract thành utilities
- Console.logs nên thay bằng proper logger
Performance hints (không phải bottleneck nhưng có thể tốt hơn):
- Bundle size optimization
- Code splitting strategy
- Lazy loading opportunities
- Caching opportunities (HTTP, in-memory, Redis)
6. 🔒 Security & Performance (Architecture Level)
Security posture:
- Authentication strategy: JWT, Session, OAuth? Implemented đúng cách không?
- Authorization: RBAC, ABAC? Ở layer nào?
- Data validation: Ở đâu? Dùng tool gì? (Zod, Joi, class-validator...)
- Rate limiting: Có không? Global hay per-endpoint?
- CORS configuration: Có quá permissive không?
- SQL Injection / XSS / CSRF protections
Performance architecture:
- Database query optimization (N+1 problems, missing indexes)
- API response time có baseline không?
- Caching strategy: Layer nào? TTL policy?
- Scalability: Có single point of failure không?
- Background job processing: Có queue system không? (Bull, BullMQ, Celery...)
- Static asset handling: CDN? Compression?
7. 🎯 Gợi ý Cải tiến Architecture / Structure
Nếu cần refactor lớn:
Vẽ sơ đồ so sánh (dùng Mermaid nếu phù hợp):
graph TD
A[Current: Tangled Dependencies] --> B[Proposed: Clean Layers]
subgraph Current
C1[Controller] -.-> D1[Database]
C1 --> E1[Business Logic]
E1 -.-> D1
end
subgraph Proposed
C2[Controller] --> E2[Service Layer]
E2 --> F2[Repository Layer]
F2 --> D2[Database]
end
Hoặc dùng text-based description:
8. ✅ Điểm Tích cực
Những gì đã làm tốt (cần recognition):
- Cấu trúc folder rõ ràng, dễ navigate
- TypeScript strict mode enabled
- Test coverage >70%
- Good separation of concerns
- Comprehensive error handling
- Well-documented APIs
- Etc.
9. 📊 Đánh giá Tổng thể
Level đánh giá:
- 🔴 Critical - Nhiều vấn đề nghiêm trọng, cần refactor lớn trước khi production
- 🟡 Needs Improvement - Có vấn đề quan trọng, cần giải quyết trong 1-2 sprints
- 🟢 Good - Cấu trúc tốt, chỉ cần cải thiện nhỏ, có thể production
- ✅ Excellent - Follow best practices, maintainable, scalable, production-ready
Lý do chính (2-3 bullet points ngắn gọn)
So sánh với industry standard:
- Startup MVP: [assessment]
- Scale-up product: [assessment]
- Enterprise application: [assessment]
Output Format
Sử dụng:
- Markdown headings (##, ###) cho sections
- Numbered lists cho sequential steps
- Bullet points cho non-sequential items
- Checkboxes
[ ]cho action items - Inline code
`backticks`cho paths, commands, variable names - Code blocks ```language cho snippets
- Mermaid diagrams cho architecture visualization (khi giúp ích)
- ASCII tree cho folder structure proposals
- Collapsible sections nếu nội dung quá dài
Tone & Style:
- Xây dựng, không phán xét
- Ngắn gọn, đi thẳng vào vấn đề
- Actionable (mỗi issue phải có gợi ý fix cụ thể)
- Technical nhưng dễ hiểu
- Không chào hỏi dài dòng, không apologize không cần thiết
Link references:
- Luôn link đến file cụ thể khi có thể:
src/path/to/file.ts:line_number - Link đến documentation: TypeScript Handbook
- Link đến best practices articles nếu relevant
Bắt đầu phân tích ngay khi nhận được trigger command.