You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/instructions/backend.instructions.md
+71-34Lines changed: 71 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,8 @@
2
2
applyTo: "**/*.java, **/*.py, **/*.cs"
3
3
---
4
4
<!-- The above section is called 'frontmatter' and is used to define metadata for the document -->
5
-
6
5
<!-- The main content of the markdown file starts here -->
7
-
# Backend Instructions
6
+
# Backend Development Guidelines
8
7
9
8
## General Guidelines
10
9
@@ -14,21 +13,7 @@ Follow idiomatic practices for the chosen programming language and framework. Pr
14
13
-**Security**: Implement security best practices, such as input validation, parameterized queries (to prevent SQL injection), and proper authentication/authorization.
15
14
-**Error Handling**: Implement robust error handling and logging to ensure system stability and ease of debugging.
16
15
-**Configuration Management**: Externalize configuration from code. Use environment variables or configuration files. Do not commit secrets to version control.
17
-
18
-
<aname="backend-architecture"></a>
19
-
## Architecture & Structure
20
-
21
-
Adopt a simple, layered architecture to keep boundaries clear and testable:
- 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.
32
17
33
18
## Language-Specific Guidelines
34
19
@@ -47,6 +32,73 @@ Testing guidance: unit-test services with fakes; integration-test controllers an
47
32
5.**REST APIs**: Use `@RestController` for creating RESTful services and DTOs (Data Transfer Objects) to decouple API contracts from domain models.
48
33
6.**Security**: Use Spring Security for authentication and authorization.
49
34
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
+
<aname="backend-architecture"></a>
84
+
## Architecture & Structure
85
+
86
+
Adopt a simple, layered architecture to keep boundaries clear and testable:
- 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.
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ This repository is intended to help teams adopt Copilot best practices, understa
24
24
25
25
## How to get started
26
26
27
+
27
28
1. Create a new repository using “Use this template” (or fork/clone).
28
29
2. Review and adapt the example [chat modes](.github/chatmodes/README.md), [instructions](.github/instructions/README.md), and [prompts](.github/prompts/README.md).
29
30
3. Read the project docs in [docs/README.md](docs/README.md).
0 commit comments