Developer & Contributor Guide โ
This document provides instructions for developers. It explains setup steps, architecture rules, coding standards, testing procedures, version rules, and release checks for the Model Context Gateway (MCG) & Semantic Proxy.
๐ Table of Contents โ
- Prerequisites & Development Environment
- Repository Structure & Architecture Conventions
- Local Development Workflow
- Automated Testing & Code Coverage
- Formatting, Linting & Static Analysis
- Version Synchronization & Release Verification
- Continuous Integration & Quality Gates
๐ ๏ธ Prerequisites & Development Environment โ
Install these tools before you start development:
| Tool / Runtime | Minimum Version | Purpose |
|---|---|---|
| .NET SDK | 10.0.x | Compiles the C# backend, Minimal APIs, Dapper repositories, and xUnit tests. |
| Node.js | 22.x LTS | Runs the Vite development server, ESLint v10, Vitest, and the React 19 UI build. |
| npm | 10.x+ | Manages packages for the frontend Single Page Application (SPA). |
| Python | 3.10+ | Runs release verification and automated version bump scripts. |
| Docker | 24.x+ | Builds multi-stage container images and runs integration test environments. |
๐๏ธ Repository Structure & Architecture Conventions โ
The repository organizes code into these domains:
โโโ Components/ # Decomposed domain modules & Minimal API mappers
โ โโโ AppKeys/ # High-entropy AppKey models, crypto, and endpoints
โ โโโ Authorization/ # RBAC access policies, group mappings, and controllers
โ โโโ Capabilities/ # Proxy endpoints, SSE/HTTP mappers, and custom tools
โ โโโ Clients/ # Registered client profiles and setup guide generators
โ โโโ Providers/ # Identity and secret provider configurations & controllers
โ โโโ Servers/ # Upstream server registry, health checks, and discovery
โโโ Core/ # Core routing engine & MCP protocol handlers
โ โโโ Protocol/ # JSON-RPC 2.0 message contracts and spec models
โ โโโ Routing/ # ClientSession, DynamicEmbeddingService, SemanticSearch
โโโ Infrastructure/ # Persistence, secrets, identity, and logging adapters
โ โโโ Identity/ # Active Directory (LDAP), OIDC, and AppKey providers
โ โโโ Logging/ # PII sanitization, structured audit logging, ring buffers
โ โโโ Persistence/ # DbConnectionFactory & Repositories (see [Database ERD](database-providers.md#unified-database-entity-relationship-diagram-erd))
โ โโโ Secrets/ # Vault KV v2, DPAPI, Environment, and AES-256-GCM crypto
โ โโโ Transports/ # SseTransport, HttpTransport, and StdioTransport
โโโ frontend/ # React 19 + Vite + TypeScript glassmorphic SPA
โ โโโ src/api/ # Typed API client layer
โ โโโ src/components/ # Domain-decomposed UI views, modals, and tabs
โ โโโ src/shared/stores/ # Zustand state management stores
โ โโโ src/test/ # Vitest component, store, and unit test suites
โโโ ModelContextGateway.Tests/ # 600+ xUnit integration, security, and contract tests
โโโ scripts/ # Release verification, version bumping, and DB DDL scripts
โโโ docs/ # Architectural specifications and user guides๐ป Local Development Workflow โ
Backend (.NET 10 C#) โ
Restore dependencies & build:
bashdotnet restore ModelContextGateway.slnx dotnet build ModelContextGateway.slnx --configuration DebugRun the gateway locally:
bash# Runs on http://localhost:8080 with ephemeral SQLite database dotnet run --project ModelContextGateway.csprojConfigure environment overrides:
bash# Custom database path and admin bypass SID MCG_DATABASE_PATH="./data/dev.db" \ MCG_MASTER_KEY="dev-master-key-32-chars-long!" \ dotnet run --project ModelContextGateway.csproj
Frontend (React 19 / Vite / TypeScript) โ
Install dependencies:
bashcd frontend npm ciStart Vite development server:
bashnpm run devThe development proxy forwards
/api,/sse, and/mcptraffic directly tohttp://localhost:8080.Build production bundle:
bashnpm run build
๐งช Automated Testing & Code Coverage โ
Backend Test Suite โ
The C# test suite contains more than 600 unit, integration, and security contract tests:
# Run all backend tests
CI=true dotnet test ModelContextGateway.slnx --configuration Release
# Collect code coverage
CI=true dotnet test ModelContextGateway.slnx --configuration Release --collect:"XPlat Code Coverage"Frontend Vitest Suite โ
The frontend test suite validates Zustand stores, typed API handlers, and React components:
cd frontend
# Run test suite once
npm test
# Run tests with coverage
npm run test:coverageEnd-to-End Testing (Playwright) โ
Run user workflows across multi-user security matrices:
cd frontend
npx playwright testLiving Software Requirements Specification (SRS) & Test Catalog โ
Tests in C# and TypeScript include annotations for requirements and safety guardrails. Use these commands to generate or verify the catalog:
# Generate human-readable Markdown and machine JSON matrix
dotnet run --project scripts/CatalogGenerator
# Verify zero-drift in CI quality gates
dotnet run --project scripts/CatalogGenerator -- --verify-only- Living SRS Document:
docs/software-requirements-and-test-catalog.md - Test Catalog & Annotation Guide:
docs/test-catalog-guide.md
๐จ Formatting, Linting & Static Analysis โ
C# Backend Formatting & Roslyn Analyzers:
bashdotnet format ModelContextGateway.slnx --verify-no-changesConfiguration rules reside in
.editorconfigandDirectory.Build.props.Frontend ESLint (Zero-Warning Policy):
bashcd frontend npm run lintThis command uses the ESLint v10 configuration in
frontend/eslint.config.js. You must resolve all warnings.
๐ Version Synchronization & Release Verification โ
Mandatory Version Synchronization Contract โ
Every release, pull request, and commit to main must update the version number in four required locations:
ModelContextGateway.csproj:<Version>X.Y.Z</Version><AssemblyVersion>X.Y.Z.0</AssemblyVersion><FileVersion>X.Y.Z.0</FileVersion>
frontend/src/shared/stores/useUserStore.ts:version: 'X.Y.Z', // fallback default
CHANGELOG.md:- Top entry row in Release Changelog table matching
| **vX.Y.Z** | YYYY-MM-DD | ... |
- Top entry row in Release Changelog table matching
README.md:- Shield badge:
 - Top entry row in the top-5 release preview table
- Shield badge:
Release Verification Script (verify-release.sh) โ
The release verification engine is located at scripts/verify_release.py. Use the bash wrapper scripts/verify-release.sh to run the suite:
# ๐ก๏ธ Run full verification suite (versions, links, tests, builds)
./scripts/verify-release.sh==================================================================
๐ก๏ธ Model Context Gateway - Release & Quality Verification Engine ๐ก๏ธ
==================================================================
Repository Root: /containers/dev/csharp-mcp-router
๐ท๏ธ 1. Version Synchronization & Consistency
------------------------------------------------------------------
[PASS] Canonical Version in ModelContextGateway.csproj
[PASS] Csproj <AssemblyVersion> Alignment
[PASS] Csproj <FileVersion> Alignment
[PASS] React Store Fallback Version (frontend/src/shared/stores/useUserStore.ts)
[PASS] CHANGELOG.md Top Entry Alignment
[PASS] README.md Version Badge Alignment
[PASS] README.md Release Preview Top Entry
๐ 2. Markdown Link & Anchor Integrity
------------------------------------------------------------------
[PASS] Scanned Markdown Files (45 files discovered)
[PASS] Relative Links & Anchor Validity (151 links verified)
๐งช 3. Backend .NET Build & Test Verification
------------------------------------------------------------------
[PASS] .NET Backend Test Suite (500+ tests)
โ๏ธ 4. Frontend Quality, Lint, Build & Vitest Verification
------------------------------------------------------------------
[PASS] Frontend ESLint Quality Check (0 warnings)
[PASS] Frontend Vite Production Build (SPA)
[PASS] Frontend Vitest Component & Store Suite
==================================================================
๐ Release Verification Summary Report ๐
==================================================================
Total Checks: 13
Passed Checks: 13
Failed Checks: 0
------------------------------------------------------------------
๐ ALL RELEASE & QUALITY GATES PASSED CLEANLY! ๐
==================================================================CLI Flags & Options Reference โ
Use these flags to control verification steps:
| Flag | Purpose | Example |
|---|---|---|
--skip-tests | Skips backend and frontend tests. Verifies versions and links in less than 2 seconds. | ./scripts/verify-release.sh --skip-tests |
--skip-links | Skips markdown link and anchor validation. | ./scripts/verify-release.sh --skip-links |
--skip-versions | Skips version synchronization checks. | ./scripts/verify-release.sh --skip-versions |
--check-versions-only | Runs only version synchronization checks. | python3 scripts/verify_release.py --check-versions-only |
--check-links-only | Runs only markdown relative link and anchor checks. | python3 scripts/verify_release.py --check-links-only |
--check-tests-only | Runs only backend and frontend test and build suites. | python3 scripts/verify_release.py --check-tests-only |
--ci | Uses simple output formatted for automated CI jobs. | python3 scripts/verify_release.py --ci |
-v, --verbose | Enables verbose logging with detailed check descriptions. | ./scripts/verify-release.sh -v |
Automated Version Bumping & Atomic Commits โ
Use ./commit.sh to bump the version and commit files atomically:
./commit.sh "feat(auth): add fine-grained category scopes"The script runs these steps:
- Validates the .NET project build.
- Runs
scripts/bump_version.pyto increment the version number. Minor versions increment forfeat:or breaking changes. Patch versions increment forfix:ordocs:. - Synchronizes version references in
.csproj,useUserStore.ts,CHANGELOG.md, andREADME.md. - Creates a clean, atomic git commit.
๐ Continuous Integration & Quality Gates โ
Pull requests to main must pass the quality gates defined in .github/workflows/ci.yml:
release-verification: Validates version synchronization and checks that markdown links and anchors are valid.backend: Compiles the release build and runs all xUnit tests with coverage collection.frontend: Enforces zero ESLint warnings, builds the Vite production SPA, and runs Vitest suites.integration-smoke: Starts the compiled release binary on a local port with an ephemeral SQLite database. Tests health endpoints, AppKey generation, and live MCP discovery.docker-check: Validates multi-stage Docker build integrity.CodeQL&Dependency Review: Runs static security analysis and scans dependencies for vulnerabilities.
For more details on CI workflows, branch protection rules, and coverage metrics, read CI Quality Gates & Security Workflows and the Code Coverage Report.