|
| 1 | +# Copilot Instructions |
| 2 | + |
| 3 | +This project features an **ASP.NET Core** backend (REST API) and a **Svelte 5 TypeScript** frontend (SPA). All contributions should respect existing formatting and conventions specified in the project’s `.editorconfig`. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 1. General Coding Guidelines |
| 8 | + |
| 9 | +- **Maintain File Style & Minimal Diffs:** |
| 10 | + - Match the code style of the file. When unsure, use the style defined in the `.editorconfig`. |
| 11 | + - Keep diffs as small as possible. Preserve existing formatting, including extra spaces and comments. |
| 12 | + |
| 13 | +- **Complete, Clear, and Modern Code:** |
| 14 | + - Write complete code for every step—no placeholders or TODOs. |
| 15 | + - Prioritize readability by using modern language features, clear naming, and clean code practices. |
| 16 | + - It's acceptable to employ defensive coding practices when needed to handle unexpected scenarios gracefully. |
| 17 | + |
| 18 | +- **Design Principles:** |
| 19 | + - Follow SOLID, DRY, and overall clean code principles. |
| 20 | + - Remove unused code; simplicity equals maintainability. |
| 21 | + |
| 22 | +- **Behavioral Changes:** |
| 23 | + - Flag any user-visible changes and review them carefully. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## 2. Frontend Guidelines (Svelte 5 / TypeScript SPA) |
| 28 | + |
| 29 | +- **Framework & Best Practices:** |
| 30 | + - Built with Svelte 5 in SPA mode using TypeScript and Tailwind CSS. |
| 31 | + - Adhere to modern ES6 best practices and the ESLint recommended configuration ([standardjs](https://standardjs.com)). |
| 32 | + |
| 33 | +- **Architecture & Components:** |
| 34 | + - Utilize the Composite Component Pattern (similar to shadcn-svelte). |
| 35 | + - Organize code using vertical slices for features with a shared folder for common components. |
| 36 | + - **Avoid** using any server-side Svelte features. |
| 37 | + |
| 38 | +- **UI, Accessibility, and Navigation:** |
| 39 | + - Ensure excellent keyboard navigation for all front-end interactions. |
| 40 | + - Leverage shadcn-svelte components, which are built on [bits-ui](https://bits-ui.com/docs/llms.txt). |
| 41 | + - Build forms using shadcn-svelte forms & superforms, and validate with class-validator. |
| 42 | + - For icons use lucide-svelte. |
| 43 | + - Follow mobile-first responsive design, semantic HTML, and secure WCAG 2.2 Level AA compliance. |
| 44 | + |
| 45 | +- **Testing:** |
| 46 | + - Unit Testing: Vitest |
| 47 | + - Component Testing: Testing Library |
| 48 | + - E2E Testing: Playwright |
| 49 | + |
| 50 | +- **Reference:** |
| 51 | + - Svelte 5 SPA guidelines: [https://svelte.dev/llms-full.txt](https://svelte.dev/llms-full.txt) |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## 3. Backend Guidelines (ASP.NET Core / C#) |
| 56 | + |
| 57 | +- **Framework & Language Features:** |
| 58 | + - Developed with the latest ASP.NET Core and C#. |
| 59 | + - Enable Nullable Reference Types. |
| 60 | + |
| 61 | +- **Coding Conventions & Best Practices:** |
| 62 | + - Follow guidelines from the `.editorconfig` and Microsoft's [coding conventions](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions). |
| 63 | + - Adhere to Microsoft's best practices for ASP.NET Core development and [unit testing with xUnit](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-best-practices). |
| 64 | + |
| 65 | +- **Architecture Considerations:** |
| 66 | + - Factor in the inherent challenges of distributed computing when designing features. |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## 4. Performance |
| 71 | + |
| 72 | +- **Optimizations:** |
| 73 | + - Lazy load components when possible. |
| 74 | + - Optimize images and assets. |
| 75 | + - Employ effective caching strategies. |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## 5. Security |
| 80 | + |
| 81 | +- **Data Protection & Validation:** |
| 82 | + - Sanitize all user inputs and validate data rigorously. |
| 83 | + - Follow OWASP guidelines and implement a robust Content Security Policy. |
| 84 | + - Embrace Shift-Left security practices. |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +## 6. Code Reviews |
| 89 | + |
| 90 | +- **Focus Areas:** |
| 91 | + - Review for complexity, consistency, duplication, and adherence to best practices. |
| 92 | + - Verify robust error handling and the effectiveness of defensive coding when applied. |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +## 7. Debugging Guidelines |
| 97 | + |
| 98 | +1. **Reproduce** the issue using minimal steps and code. |
| 99 | +2. **Understand** the core problem. |
| 100 | +3. **Hypothesize** the root cause. |
| 101 | +4. **Test & Verify** the solution. |
| 102 | +5. **Document** the fix and any adjustments made. |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +## 8. Project Structure |
| 107 | + |
| 108 | +```plaintext |
| 109 | +project-root/ |
| 110 | +├── build # Build files |
| 111 | +├── docker # Docker files |
| 112 | +├── k8s # Kubernetes files |
| 113 | +├── samples |
| 114 | +├── src |
| 115 | +│ ├── Exceptionless.AppHost # Aspire |
| 116 | +│ ├── Exceptionless.Core # Domain |
| 117 | +│ ├── Exceptionless.EmailTemplates # Email Templates |
| 118 | +│ ├── Exceptionless.Insulation # Concrete Implementations |
| 119 | +│ ├── Exceptionless.Job # ASP.NET Core Jobs |
| 120 | +│ ├── Exceptionless.Web # ASP.NET Core Web Application |
| 121 | +│ │ ├── ClientApp # Frontend SvelteKit Spa Application |
| 122 | +│ │ │ ├── api-templates # API templates for generated code using OpenApi |
| 123 | +│ │ │ ├── e2e |
| 124 | +│ │ │ ├── src # JavaScript SvelteKit application |
| 125 | +│ │ │ │ ├── lib |
| 126 | +│ │ │ │ │ ├── assets # Static assets |
| 127 | +│ │ │ │ │ ├── features # Vertical Sliced Features, each folder corresponds to an api controller |
| 128 | +│ │ │ │ │ │ ├── events # Event features (related to Events Controller) |
| 129 | +│ │ │ │ │ │ │ ├── components |
| 130 | +│ │ │ │ │ │ │ └── models |
| 131 | +│ │ │ │ │ │ ├── organizations |
| 132 | +│ │ │ │ │ │ ├── projects |
| 133 | +│ │ │ │ │ │ │ └── components |
| 134 | +│ │ │ │ │ │ ├── shared # Shared components used by all other features |
| 135 | +│ │ │ │ │ │ │ ├── api |
| 136 | +│ │ │ │ │ │ │ ├── components |
| 137 | +│ │ │ │ │ │ │ └── models |
| 138 | +│ │ │ │ │ │ ├── stacks |
| 139 | +│ │ │ │ │ │ │ └── components |
| 140 | +│ │ │ │ │ ├── generated # Generated code |
| 141 | +│ │ │ │ │ ├── hooks # Client hooks |
| 142 | +│ │ │ │ │ └── utils # Utility functions |
| 143 | +│ │ │ │ └── routes # Application routes |
| 144 | +│ │ │ │ ├── (app) |
| 145 | +│ │ │ │ │ ├── account |
| 146 | +│ │ │ │ │ └── stream |
| 147 | +│ │ │ │ ├── (auth) |
| 148 | +│ │ │ │ │ ├── login |
| 149 | +│ │ │ │ │ └── logout |
| 150 | +│ │ │ │ └── status |
| 151 | +│ │ │ └── static # Static assets |
| 152 | +│ │ ├── ClientApp.angular # Legacy Angular Client Application (Ignore) |
| 153 | +│ │ ├── Controllers # ASP.NET Core Web API Controllers |
| 154 | +│ └── tests # ASP.NET Core Unit and Integration Tests |
| 155 | +``` |
| 156 | + |
| 157 | +--- |
| 158 | + |
| 159 | +### Additional Considerations |
| 160 | + |
| 161 | +- **Expanding the Guidelines:** |
| 162 | + As the project evolves, consider including sample code snippets, decision flowcharts, or ASCII diagrams to clarify more complex guidelines. |
| 163 | + |
| 164 | +- **Continuous Improvement:** |
| 165 | + Regularly review and update these guidelines to stay aligned with evolving best practices and emerging technologies. |
| 166 | + |
| 167 | +- **Thoughtful Contribution:** |
| 168 | + Always strive to deliver code that not only functions well but also advances the overall maintainability and quality of the project. |
| 169 | + |
| 170 | +Let's keep pushing for clarity, usability, and excellence—both in code and user experience. |
0 commit comments