Skip to content

Commit 1f3fabc

Browse files
committed
Eliminate merge conflicts
1 parent 6b14e87 commit 1f3fabc

File tree

2 files changed

+72
-34
lines changed

2 files changed

+72
-34
lines changed

.github/instructions/backend.instructions.md

Lines changed: 71 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
applyTo: "**/*.java, **/*.py, **/*.cs"
33
---
44
<!-- The above section is called 'frontmatter' and is used to define metadata for the document -->
5-
65
<!-- The main content of the markdown file starts here -->
7-
# Backend Instructions
6+
# Backend Development Guidelines
87

98
## General Guidelines
109

@@ -14,21 +13,7 @@ Follow idiomatic practices for the chosen programming language and framework. Pr
1413
- **Security**: Implement security best practices, such as input validation, parameterized queries (to prevent SQL injection), and proper authentication/authorization.
1514
- **Error Handling**: Implement robust error handling and logging to ensure system stability and ease of debugging.
1615
- **Configuration Management**: Externalize configuration from code. Use environment variables or configuration files. Do not commit secrets to version control.
17-
18-
<a name="backend-architecture"></a>
19-
## Architecture & Structure
20-
21-
Adopt a simple, layered architecture to keep boundaries clear and testable:
22-
- Entry (HTTP/CLI/Queue) → Controller/Handler → Service (business logic) → Repository (data access) → External systems.
23-
- Keep DTOs separate from domain models; map at edges.
24-
- Inject dependencies through constructors. Avoid singletons and global state.
25-
26-
Language-specific notes:
27-
- Spring Boot: Controllers (`@RestController`) → Services (`@Service`) → Repos (`@Repository`). Use packages by feature when helpful.
28-
- Django: Views/ViewSets → Services (plain modules) → ORM Models/Managers. Keep fat models thin services as needed; avoid business logic in views.
29-
- ASP.NET Core: Controllers → Services (DI) → Repositories (EF Core). Prefer interfaces for services/repositories for testability.
30-
31-
Testing guidance: unit-test services with fakes; integration-test controllers and repositories. See `.github/copilot-instructions.md#quality-policy` for coverage expectations.
16+
- **Testing**: Write unit tests for business logic and integration tests for critical paths. Aim for high test coverage, especially on new code.
3217

3318
## Language-Specific Guidelines
3419

@@ -47,6 +32,73 @@ Testing guidance: unit-test services with fakes; integration-test controllers an
4732
5. **REST APIs**: Use `@RestController` for creating RESTful services and DTOs (Data Transfer Objects) to decouple API contracts from domain models.
4833
6. **Security**: Use Spring Security for authentication and authorization.
4934

35+
### Python
36+
37+
- **Dependency Management**: Use `pip` with `requirements.txt` or a tool like Poetry or Pipenv.
38+
- **Coding Style**: Follow PEP 8.
39+
- **Virtual Environments**: Always use a virtual environment (e.g., `venv`).
40+
41+
#### Django
42+
43+
- **Project Structure**: Follow the standard Django project structure (`manage.py`, project folder, app folders).
44+
- **ORM**: Use the Django ORM for database interactions.
45+
- **Settings**: Manage settings for different environments carefully (e.g., `settings/base.py`, `settings/dev.py`, `settings/prod.py`).
46+
- **Security**: Use Django's built-in security features (e.g., CSRF protection, XSS protection).
47+
48+
#### Flask
49+
50+
- **Project Structure**: Use Blueprints to organize larger applications.
51+
- **ORM**: Use SQLAlchemy with Flask-SQLAlchemy for database interactions.
52+
- **Configuration**: Use instance folders for configuration.
53+
54+
### C#/.NET
55+
56+
- **Project Structure**: Follow the standard .NET project structure.
57+
- **Dependency Management**: Use NuGet for package management.
58+
- **Coding Style**: Follow the Microsoft C# Coding Conventions.
59+
- **Async/Await**: Use `async` and `await` for non-blocking I/O operations.
60+
61+
#### ASP.NET Core
62+
63+
1. **Configuration**: Use `appsettings.json` and environment-specific variants (`appsettings.Development.json`).
64+
2. **Dependency Injection**: Use the built-in dependency injection container.
65+
3. **ORM**: Use Entity Framework Core for database access.
66+
4. **API Development**: Use controllers for API endpoints and follow RESTful principles.
67+
5. **Security**: Use ASP.NET Core Identity for authentication and authorization.
68+
69+
<!-- Removed duplicated placeholder sections to avoid conflicts; guidance above already covers Flask, Django, and ASP.NET Core. -->
70+
71+
## API Development
72+
73+
1. **Endpoint Design**: Design RESTful APIs with clear and consistent endpoint structures.
74+
2. **Request/Response Formats**: Follow the API guidelines for request/response formats (e.g., JSON).
75+
3. **Versioning**: Implement the API versioning strategy defined in the docs to ensure backward compatibility.
76+
77+
## Performance Optimization
78+
79+
1. **Caching**: Implement caching strategies to reduce database load and improve response times.
80+
2. **Database Optimization**: Optimize database queries and use indexing where appropriate.
81+
3. **Asynchronous Processing**: Use asynchronous processing for long-running tasks to improve API responsiveness.
82+
83+
<a name="backend-architecture"></a>
84+
## Architecture & Structure
85+
86+
Adopt a simple, layered architecture to keep boundaries clear and testable:
87+
- Entry (HTTP/CLI/Queue) → Controller/Handler → Service (business logic) → Repository (data access) → External systems.
88+
- Keep DTOs separate from domain models; map at edges.
89+
- Inject dependencies through constructors. Avoid singletons and global state.
90+
91+
Framework-specific notes:
92+
- Spring Boot: Controllers (`@RestController`) → Services (`@Service`) → Repos (`@Repository`). Use packages by feature when helpful.
93+
- Django: Views/ViewSets → Services (plain modules) → ORM Models/Managers. Keep fat models thin services as needed; avoid business logic in views.
94+
- ASP.NET Core: Controllers → Services (DI) → Repositories (EF Core). Prefer interfaces for services/repositories for testability.
95+
96+
Testing guidance: unit-test services with fakes; integration-test controllers and repositories. See `.github/copilot-instructions.md#quality-policy` for coverage expectations.
97+
98+
<a name="backend-error-handling"></a>
99+
100+
## Error Handling
101+
50102
##### Example: Global Exception Handler (Spring)
51103
```java
52104
@RestControllerAdvice
@@ -136,22 +188,6 @@ app.UseExceptionHandler(appError =>
136188
});
137189
```
138190

139-
<!-- Removed duplicated placeholder sections to avoid conflicts; guidance above already covers Flask, Django, and ASP.NET Core. -->
140-
141-
## API Development
142-
143-
1. **Endpoint Design**: Design RESTful APIs with clear and consistent endpoint structures.
144-
2. **Request/Response Formats**: Follow the API guidelines for request/response formats (e.g., JSON).
145-
3. **Versioning**: Implement the API versioning strategy defined in the docs to ensure backward compatibility.
146-
147-
Return consistent error shapes (code, message, correlationId) and map exceptions to appropriate status codes. Do not leak stack traces to clients.
148-
149-
## Performance Optimization
150-
151-
1. **Caching**: Implement caching strategies to reduce database load and improve response times.
152-
2. **Database Optimization**: Optimize database queries and use indexing where appropriate.
153-
3. **Asynchronous Processing**: Use asynchronous processing for long-running tasks to improve API responsiveness.
154-
155191
<a name="backend-error-handling"></a>
156192
## Error Handling
157193

@@ -171,6 +207,8 @@ Return consistent error shapes (code, message, correlationId) and map exceptions
171207
- Metrics: instrument hot paths, DB calls, external requests; standard RED/USE metrics.
172208
- Tracing: propagate trace headers (W3C TraceContext). Use OpenTelemetry SDKs where available.
173209

210+
Return consistent error shapes (code, message, correlationId) and map exceptions to appropriate status codes. Do not leak stack traces to clients.
211+
174212
Examples:
175213
```java
176214
// Spring: add correlation ID to MDC
@@ -201,4 +239,3 @@ using (logger.BeginScope(new Dictionary<string, object>{{"correlationId", cid}})
201239
References:
202240
- Branch/PR workflow and conventions: `.github/copilot-instructions.md`.
203241
- Coverage and critical-path rules: `.github/copilot-instructions.md#quality-policy`.
204-

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This repository is intended to help teams adopt Copilot best practices, understa
2424

2525
## How to get started
2626

27+
2728
1. Create a new repository using “Use this template” (or fork/clone).
2829
2. Review and adapt the example [chat modes](.github/chatmodes/README.md), [instructions](.github/instructions/README.md), and [prompts](.github/prompts/README.md).
2930
3. Read the project docs in [docs/README.md](docs/README.md).

0 commit comments

Comments
 (0)