基于.NET 8的新西兰发票系统SaaS

高质量提示示例与最佳实践指南

研究总结

用户需求翻译: ".NET 8-based SaaS invoice printing system for New Zealand market, where users provide invoice details and the system generates a PDF invoice"

🚀 推荐技术栈

🔍 研究关键词

QuestPDF Multi-tenant patterns JWT authentication Clean Architecture Azure SQL Elastic Pools GST compliance CQRS MediatR Docker containerization HTML to PDF conversion Repository pattern
搜索查询记录:
• ".NET 8 SaaS invoice printing system PDF generation"
• "New Zealand invoice requirements GST tax compliance .NET SaaS"
• ".NET 8 SaaS architecture multi-tenant invoice system patterns"
• "ASP.NET Core API authentication authorization JWT SaaS patterns"
• ".NET 8 invoice PDF template engine design patterns clean architecture"
💻 项目初始化提示
技术栈选择与项目架构
Create a .NET 8 invoice system using QuestPDF for PDF generation. Include support for New Zealand GST requirements, multi-tenant architecture, and clean architecture patterns. Implement JWT authentication, Azure SQL with elastic pools, and Docker containerization for scalable SaaS deployment.
预期用途
项目初始化、技术栈选择、整体架构规划
🏗️ 架构设计提示
多租户架构设计
Design a multi-tenant invoice system using .NET 8 with tenant isolation at the database level. Implement shared database with tenant ID filtering, elastic pool strategy for cost optimization, and tenant-specific routing. Support up to 500 databases per pool with automatic resource balancing.
预期用途
多租户系统架构设计、数据隔离策略
清洁架构实现
Implement Clean Architecture in .NET 8 with Domain, Application, Infrastructure, and Presentation layers. Use Repository pattern for data access, CQRS with MediatR for business logic separation, and domain events for loose coupling between bounded contexts.
预期用途
代码组织结构、层次分离、可维护性设计
CQRS与领域事件
Implement CQRS with MediatR in .NET 8 for invoice domain events. Create InvoiceCreatedEvent, InvoiceUpdatedEvent, and InvoicePaidEvent handlers. Implement audit trails, separate read/write operations for scalability, and use async/await patterns consistently.
预期用途
业务逻辑分离、事件驱动架构、性能优化
🔐 安全认证提示
JWT认证与授权
Implement JWT bearer authentication in ASP.NET Core API for a multi-tenant SaaS application. Include role-based authorization with Admin/User roles, refresh token patterns for security, tenant-specific claims for data isolation, and OpenID Connect compliance for enterprise integration.
预期用途
用户认证、API安全、多租户权限控制
📋 法规合规提示
新西兰GST合规要求
Implement New Zealand GST invoice compliance for a SaaS application. Include taxable supply information (TSI) instead of traditional tax invoices, support GST registration validation, implement PEPPOL electronic invoicing standards, and ensure 7-year record retention with flexible invoice formats (PDF, email, API data exchange).
预期用途
税务合规、法律要求实现、电子发票标准
📄 PDF生成与模板提示
QuestPDF专业发票模板
Implement a professional invoice template using QuestPDF Fluent API in .NET 8. Include header with company branding and SVG logo, customer and billing address sections, itemized table with GST calculations, payment terms, and multi-page support with repeating headers/footers. Generate invoices with fewer than 250 lines of code.
预期用途
PDF生成实现、发票模板设计、专业文档格式
HTML模板引擎
Create customizable HTML invoice templates with CSS styling for PDF conversion. Support dynamic content injection using Handlebars or Razor template engine, implement SVG logos for quality scaling, professional multi-page layouts with headers/footers, and responsive design for browser preview before PDF generation.
预期用途
模板定制、HTML转PDF、动态内容生成
💾 数据库优化提示
Azure弹性池成本优化
Design Azure SQL Elastic Pool strategy for multi-tenant SaaS with cost optimization. Implement automatic resource balancing for unpredictable workloads, achieve up to 55% cost savings through Azure Hybrid Benefits, support 500 databases per pool, and use eDTU/vCore scaling based on aggregate tenant usage patterns.
预期用途
数据库架构、成本控制、性能优化
🐳 部署运维提示
Docker容器化最佳实践
Containerize .NET 8 SaaS application using Docker with multi-stage builds for optimization. Implement non-root security practices, achieve 40% image size reduction, use GitHub Actions for CI/CD pipeline with automated testing, deploy to any Linux server, and support horizontal scaling with container orchestration.
预期用途
容器化部署、CI/CD自动化、安全运维
🛠️ 错误调试提示
多租户数据隔离调试
Debug multi-tenant data isolation issues in .NET 8 invoice system. Implement global query filters for tenant ID, use EF Core interceptors for automatic tenant context injection, add comprehensive logging for tenant resolution, and create unit tests for data isolation validation across different tenant contexts.
预期用途
问题排查、数据安全验证、系统调试
PDF生成性能优化
Optimize PDF generation performance in .NET 8 invoice system. Implement async PDF generation using background services, add caching for frequently used templates, use memory-efficient streaming for large invoices, implement retry policies for failed generations, and monitor PDF generation metrics with Application Insights.
预期用途
性能调优、异步处理、监控告警
实施建议

🎯 开发优先级

  1. 第一阶段: 搭建Clean Architecture基础框架,实现基本的多租户数据隔离
  2. 第二阶段: 集成QuestPDF实现专业发票生成,满足新西兰GST合规要求
  3. 第三阶段: 实现JWT认证系统和基于角色的权限控制
  4. 第四阶段: 优化Azure SQL弹性池配置,实现成本控制和性能监控
  5. 第五阶段: Docker容器化和CI/CD流水线部署

⚠️ 关键注意事项