Skip to content

Commit c6568e1

Browse files
Create static GitHub Copilot instructions file and restore environment setup workflow (#771)
This PR addresses feedback to properly separate concerns between environment setup and documentation: ## What Changed 1. **Created static `copilot-instructions.md` file** - A comprehensive documentation file committed directly to the repository following [GitHub Copilot best practices](https://gh.io/copilot-coding-agent-tips) 2. **Restored workflow to environment setup focus** - The `copilot-setup-steps.yml` workflow now focuses solely on setting up the development environment needed to run the application ## The Copilot Instructions File The `.github/copilot-instructions.md` file provides comprehensive documentation for GitHub Copilot agents including: - **Project Overview**: Essential C# web platform architecture and purpose - **Tech Stack Details**: .NET 9, ASP.NET Core, Semantic Kernel, Entity Framework, Docker - **Development Patterns**: Coding conventions, file organization, dependency injection patterns - **Testing Strategy**: xUnit setup, testing frameworks, and AAA pattern conventions - **Build Commands**: Essential dotnet commands for development and deployment - **Configuration Guide**: Required secrets, user-secrets setup, OAuth configuration - **AI Integration**: Semantic Kernel patterns, vector database usage, chat services - **Best Practices**: Security guidelines, performance considerations, anti-patterns ## Environment Setup Workflow The workflow now focuses exclusively on preparing the development environment with: - .NET 9.0 SDK with private NuGet feed access - Docker containerization setup and validation - Azure CLI and GitHub CLI tools - Entity Framework Core CLI tools - Node.js for frontend development - Comprehensive testing and validation of all tools This separation ensures the workflow serves its intended purpose of environment preparation while the instructions file provides static, comprehensive documentation that Copilot agents can reference for accurate code generation. <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: BenjaminMichaelis <[email protected]> Co-authored-by: Benjamin Michaelis <[email protected]>
1 parent 6d84690 commit c6568e1

File tree

2 files changed

+329
-0
lines changed

2 files changed

+329
-0
lines changed

.github/copilot-instructions.md

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
# GitHub Copilot Instructions for EssentialCSharp.Web
2+
3+
## Project Overview & Core Purpose
4+
This is a comprehensive ASP.NET Core 9.0 web application ecosystem for the **Essential C#** programming education platform. The project serves as the technical foundation for [essentialcsharp.com](https://essentialcsharp.com/), providing educational content, AI-powered chat assistance, and user management for C# learning resources.
5+
6+
**Key Value**: Provides an interactive learning platform where developers can access Essential C# content, engage with AI-powered assistance for C# questions, and track their learning progress through a modern web interface.
7+
8+
**Target Audience**: C# developers at all levels, students learning C#, and educators teaching C# programming concepts.
9+
10+
## Project Structure & Architecture
11+
This solution follows a modular architecture with clear separation of concerns:
12+
13+
```
14+
EssentialCSharp.Web.sln
15+
├── EssentialCSharp.Web/ # Main ASP.NET Core web application
16+
│ ├── Areas/ # Identity and feature-specific areas
17+
│ ├── Controllers/ # MVC controllers
18+
│ ├── Views/ # Razor views and layouts
19+
│ ├── Models/ # View models and data models
20+
│ ├── Services/ # Business logic services
21+
│ ├── Migrations/ # Entity Framework migrations
22+
│ └── wwwroot/ # Static assets (CSS, JS, images)
23+
├── EssentialCSharp.Chat/ # Console application for AI chat
24+
├── EssentialCSharp.Chat.Shared/ # Shared models and services
25+
├── EssentialCSharp.Web.Tests/ # Integration tests for web app
26+
└── EssentialCSharp.Chat.Tests/ # Unit tests for chat functionality
27+
```
28+
29+
## Tech Stack & Core Technologies
30+
31+
### Framework & Runtime
32+
- **.NET 9.0** with **C# 13** language features
33+
- **ASP.NET Core 9.0** for web application framework
34+
- **Entity Framework Core 8.0.10** for data access with SQL Server
35+
- **ASP.NET Core Identity** for user authentication and authorization
36+
37+
### AI & Chat Integration
38+
- **Microsoft Semantic Kernel 1.60.0** for AI orchestration
39+
- **Azure OpenAI** integration for chat functionality
40+
- **pgvector with PostgreSQL** for vector database operations
41+
- **Model Context Protocol (MCP)** for AI agent integration
42+
43+
### Authentication & Security
44+
- **GitHub OAuth** integration for developer authentication
45+
- **Microsoft Account** authentication support
46+
- **HCaptcha** for bot protection
47+
- **JWT tokens** for API authentication
48+
49+
### Development & Deployment
50+
- **Docker** containerization with multi-stage builds
51+
- **Azure Application Insights** for telemetry and monitoring
52+
- **Azure Monitor OpenTelemetry** for observability
53+
- **Mailjet API** for email services
54+
55+
### Package Management & Build
56+
- **Central Package Management** via `Directory.Packages.props`
57+
- **Private NuGet feed** from Azure DevOps for internal packages
58+
- **Source Link** for debugging support
59+
- **Build versioning** with continuous integration support
60+
61+
## Coding Conventions & Development Patterns
62+
63+
### Project Structure Conventions
64+
- **Areas**: Use for Identity and distinct feature modules
65+
- **Controllers**: Follow MVC pattern with async actions
66+
- **Services**: Implement business logic with dependency injection
67+
- **Models**: Separate view models from domain models
68+
- **Extensions**: Place extension methods in dedicated Extension classes
69+
70+
### Code Style & Patterns
71+
- **Async/Await**: Use consistently for all I/O operations
72+
- **Dependency Injection**: Register services in `Program.cs`
73+
- **Repository Pattern**: Implement for data access abstraction
74+
- **Error Handling**: Use structured logging and custom exceptions
75+
- **Configuration**: Use strongly-typed configuration classes
76+
77+
### File Naming & Organization
78+
- **Controllers**: `{Feature}Controller.cs` (e.g., `HomeController.cs`)
79+
- **Services**: `{Feature}Service.cs` and `I{Feature}Service.cs`
80+
- **Models**: `{Entity}Model.cs` for view models, `{Entity}.cs` for domain
81+
- **Extensions**: `{Type}Extensions.cs`
82+
- **Tests**: `{ClassUnderTest}Tests.cs`
83+
84+
## Testing Strategy & Frameworks
85+
86+
### Test Organization
87+
- **Integration Tests**: `EssentialCSharp.Web.Tests` using `Microsoft.AspNetCore.Mvc.Testing`
88+
- **Unit Tests**: `EssentialCSharp.Chat.Tests` using `xUnit` and `Moq`
89+
- **Test Structure**: Follow AAA pattern (Arrange, Act, Assert)
90+
91+
### Testing Tools
92+
- **xUnit 2.9.3** as the primary testing framework
93+
- **Moq 4.20.72** for mocking dependencies
94+
- **Coverlet** for code coverage collection
95+
- **Microsoft.AspNetCore.Mvc.Testing** for integration testing
96+
97+
### Test Conventions
98+
```csharp
99+
[Fact]
100+
public async Task MethodName_Scenario_ExpectedBehavior()
101+
{
102+
// Arrange
103+
var service = new TestService();
104+
105+
// Act
106+
var result = await service.MethodAsync();
107+
108+
// Assert
109+
Assert.NotNull(result);
110+
}
111+
```
112+
113+
## Build & Development Commands
114+
115+
### Essential Commands
116+
```bash
117+
# Restore all packages
118+
dotnet restore
119+
120+
# Build entire solution
121+
dotnet build --configuration Release --no-restore
122+
123+
# Run all tests
124+
dotnet test --no-build --configuration Release
125+
126+
# Run web application
127+
dotnet run --project EssentialCSharp.Web
128+
129+
# Run chat application
130+
dotnet run --project EssentialCSharp.Chat
131+
132+
# Entity Framework operations
133+
dotnet ef migrations add MigrationName --project EssentialCSharp.Web
134+
dotnet ef database update --project EssentialCSharp.Web
135+
```
136+
137+
### Docker Operations
138+
```bash
139+
# Build Docker image
140+
docker build -t essentialcsharp-web -f EssentialCSharp.Web/Dockerfile .
141+
142+
# Run with Docker Compose (if available)
143+
docker-compose up --build
144+
```
145+
146+
## Configuration & Environment Setup
147+
148+
### Required Secrets (Use dotnet user-secrets)
149+
```bash
150+
# Email configuration
151+
dotnet user-secrets set "AuthMessageSender:SendFromName" "Essential C# Team"
152+
dotnet user-secrets set "AuthMessageSender:SendFromEmail" "[email protected]"
153+
dotnet user-secrets set "AuthMessageSender:SecretKey" "your-mailjet-secret"
154+
dotnet user-secrets set "AuthMessageSender:APIKey" "your-mailjet-api-key"
155+
156+
# OAuth providers
157+
dotnet user-secrets set "Authentication:Microsoft:ClientSecret" "microsoft-oauth-secret"
158+
dotnet user-secrets set "Authentication:Microsoft:ClientId" "microsoft-oauth-client-id"
159+
dotnet user-secrets set "Authentication:github:clientSecret" "github-oauth-secret"
160+
dotnet user-secrets set "Authentication:github:clientId" "github-oauth-client-id"
161+
162+
# Security
163+
dotnet user-secrets set "HCaptcha:SiteKey" "hcaptcha-site-key"
164+
dotnet user-secrets set "HCaptcha:SecretKey" "hcaptcha-secret-key"
165+
166+
# Application Insights
167+
dotnet user-secrets set "APPLICATIONINSIGHTS_CONNECTION_STRING" "your-app-insights-connection"
168+
```
169+
170+
### Package Feed Configuration
171+
- Set `<AccessToNugetFeed>false</AccessToNugetFeed>` in `Directory.Packages.props` if you don't have access to private Azure DevOps feed
172+
- Private feed contains `EssentialCSharp.Shared.Models` and content packages
173+
174+
## AI Integration Patterns
175+
176+
### Semantic Kernel Usage
177+
- **Chat Services**: Implement AI chat functionality using Semantic Kernel
178+
- **Vector Operations**: Use pgvector for semantic search and retrieval
179+
- **Model Context Protocol**: Integrate with MCP for agent communication
180+
- **Prompt Engineering**: Store prompts as structured templates
181+
182+
### AI Service Patterns
183+
```csharp
184+
public interface IChatService
185+
{
186+
Task<ChatResponse> ProcessMessageAsync(string message, CancellationToken cancellationToken);
187+
Task<IEnumerable<SearchResult>> SearchContentAsync(string query, CancellationToken cancellationToken);
188+
}
189+
```
190+
191+
## Development Workflow & Best Practices
192+
193+
### Code Review Guidelines
194+
- Ensure all new code includes appropriate tests
195+
- Follow established naming conventions and patterns
196+
- Use async/await for all I/O operations
197+
- Implement proper error handling and logging
198+
- Add XML documentation for public APIs
199+
200+
### Performance Considerations
201+
- Use Entity Framework efficiently (avoid N+1 queries)
202+
- Implement caching where appropriate
203+
- Use async patterns for database and API calls
204+
- Optimize Docker image size with multi-stage builds
205+
206+
### Security Best Practices
207+
- Never commit secrets to source control
208+
- Use HTTPS for all external communications
209+
- Implement proper input validation
210+
- Follow OWASP security guidelines
211+
- Use parameterized queries for database operations
212+
213+
## Common Patterns & Utilities
214+
215+
### Service Registration Pattern
216+
```csharp
217+
// In Program.cs
218+
builder.Services.AddScoped<IFeatureService, FeatureService>();
219+
builder.Services.AddSingleton<ICacheService, CacheService>();
220+
```
221+
222+
### Configuration Pattern
223+
```csharp
224+
public class FeatureOptions
225+
{
226+
public const string SectionName = "Feature";
227+
public string ApiKey { get; set; } = string.Empty;
228+
public int TimeoutSeconds { get; set; } = 30;
229+
}
230+
231+
// Registration
232+
builder.Services.Configure<FeatureOptions>(
233+
builder.Configuration.GetSection(FeatureOptions.SectionName));
234+
```
235+
236+
### Error Handling Pattern
237+
```csharp
238+
public async Task<Result<T>> MethodAsync<T>()
239+
{
240+
try
241+
{
242+
var result = await SomeOperationAsync();
243+
return Result<T>.Success(result);
244+
}
245+
catch (SpecificException ex)
246+
{
247+
logger.LogError(ex, "Operation failed");
248+
return Result<T>.Failure(ex.Message);
249+
}
250+
}
251+
```
252+
253+
## Future Roadmap Considerations
254+
- **Microservices Evolution**: Consider splitting into microservices as features grow
255+
- **Performance Optimization**: Implement advanced caching and CDN strategies
256+
- **AI Enhancement**: Expand AI capabilities with more sophisticated models
257+
- **Mobile Support**: Potential mobile app integration
258+
- **API Expansion**: RESTful API for third-party integrations
259+
260+
## Anti-Patterns & Gotchas
261+
- **Avoid**: Synchronous calls in async methods (use ConfigureAwait(false))
262+
- **Avoid**: Large Entity Framework queries without pagination
263+
- **Avoid**: Hardcoded configuration values (use appsettings.json)
264+
- **Avoid**: Missing error handling in async operations
265+
- **Security**: Never expose sensitive configuration in client-side code
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Setup GitHub Copilot Agent Environment
2+
3+
# This workflow configures the environment for GitHub Copilot agents
4+
# It reuses configuration from the main Build-Test-And-Deploy workflow
5+
# to ensure consistency and reduce duplication
6+
7+
on:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
setup-environment:
15+
runs-on: ubuntu-latest
16+
environment: "BuildAndUploadImage"
17+
18+
steps:
19+
- uses: actions/checkout@v5
20+
21+
- name: Set up .NET Core
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
global-json-file: global.json
25+
source-url: https://pkgs.dev.azure.com/intelliTect/_packaging/EssentialCSharp/nuget/v3/index.json
26+
env:
27+
NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_PAT }}
28+
29+
- name: Set up dependency caching for faster builds
30+
uses: actions/cache@v4
31+
id: nuget-cache
32+
with:
33+
path: |
34+
~/.nuget/packages
35+
${{ github.workspace }}/**/obj/project.assets.json
36+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
37+
restore-keys: |
38+
${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
39+
${{ runner.os }}-nuget-
40+
41+
- name: Restore with dotnet
42+
run: dotnet restore
43+
44+
- name: Build with dotnet
45+
run: dotnet build -p:ContinuousIntegrationBuild=True -p:ReleaseDateAttribute=True --configuration Release --no-restore
46+
47+
- name: Run .NET Tests
48+
run: dotnet test --no-build --configuration Release
49+
50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v3
52+
53+
- name: Set up Node.js for frontend development
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: '20'
57+
58+
- name: Install additional development tools
59+
run: |
60+
# Install common development tools that Copilot agents might need
61+
echo "Installing additional tools for Copilot agent environment..."
62+
63+
# Install EF Core tools globally
64+
dotnet tool install --global dotnet-ef

0 commit comments

Comments
 (0)