How sam-raiden/react-dotnet-example works
Purpose and Entry Points
This is a React + ASP.NET Core example application centered on user management. The backend starts through Program.cs, configures HTTP services and middleware in Startup.cs, and exposes a user API via Controllers/UsersController.cs. The browser application enters through ClientApp/src/index.js and renders ClientApp/src/App.js.
ASP.NET Core Host and API Boundary
The .NET project (react-dotnet-example.csproj) hosts the API and likely serves or coordinates the React build. Startup.cs is the architectural boundary for dependency injection, routing, CORS/static-file behavior, and SPA integration. Controllers/UsersController.cs defines the HTTP-facing contract consumed by the client.
User Domain and Persistence Abstraction
The domain is deliberately small: Models/User.cs represents user data, while Models/IUserRepository.cs separates API/controller logic from storage implementation. Models/UserRepository.cs supplies the concrete repository, making it the replacement point for a database-backed implementation without changing controller consumers.
Client Application and UI Stages
React owns the interactive user workflow. ClientApp/src/App.js composes the application shell; ClientApp/src/components/Header.js provides page-level navigation/header UI. User creation and presentation are split into ClientApp/src/components/CreateUser.js, ClientApp/src/components/Users.js, and ClientApp/src/components/DisplayBoard.js, allowing input, retrieval, and display responsibilities to remain distinct.
Client-to-API Data Flow
UI components call ClientApp/src/services/UserService.js, which is the frontend transport boundary for the backend user endpoints. The expected flow is: create/list action in a React component → UserService HTTP request → UsersController → IUserRepository/UserRepository → user data returned to React for board/list rendering. This service layer is the primary place to change endpoint URLs, request formats, authentication headers, or error handling.
Runtime and Delivery
The application requires a .NET Core/ASP.NET Core runtime and Node/npm tooling for the React client, indicated by react-dotnet-example.csproj and ClientApp/package.json. Dockerfile defines container packaging. Kubernetes deployment resources in kube/deployment.yml, kube/service.yml, and kube/manifest.yml provide the operational boundary for running the container behind a cluster Service.
Configuration and Environment Boundaries
Server configuration is sourced from appsettings.json and environment-specific overrides in appsettings.Development.json. The client has its own environment file at ClientApp/.env. These are separate configuration scopes: server settings affect ASP.NET hosting/services, while client settings are embedded or applied during the React build/runtime process.
Main entry points: App.js App shell · Startup.cs Startup · UserService.js User service · Users.js Users
Components 21
ASP.NET Core Server
- .NET project · Hosts the API and coordinates the client application.
react-dotnet-example.csproj - Program
Program.cs - Startup · Configures DI, middleware, routing, and SPA behavior.
Startup.cs - Users API · User endpoint contract consumed by React.
Controllers/UsersController.cs - User
Models/User.cs - User repository contract
Models/IUserRepository.cs - User repository · Storage replacement point for the user domain.
Models/UserRepository.cs - Server configuration · Base and development ASP.NET settings.
appsettings.json
React Client
- Client package · Node/npm tooling and client dependencies.
ClientApp/package.json - React entry
ClientApp/src/index.js - App shell
ClientApp/src/App.js - Header
ClientApp/src/components/Header.js - Create user · Collects user creation input.
ClientApp/src/components/CreateUser.js - Users · Retrieves and presents user data.
ClientApp/src/components/Users.js - Display board · Renders user results.
ClientApp/src/components/DisplayBoard.js - User service · Centralizes HTTP requests and API concerns.
ClientApp/src/services/UserService.js - Client environment · Client build/runtime environment scope.
ClientApp/.env
Container & Kubernetes
- Container image
Dockerfile - Kubernetes deployment
kube/deployment.yml - Kubernetes service
kube/service.yml - Kubernetes manifest
kube/manifest.yml
Connections 23
- .NET project → Program: builds
- Program → Startup: starts
- Startup → Users API: routes to
- Startup → User repository contract: registers
- Server configuration → Startup: configures
- Users API → User repository contract: depends on
- User repository contract → User repository: implemented by
- User repository → User: stores
- Client package → React entry: builds
- React entry → App shell: renders
- App shell → Header: composes
- App shell → Create user: composes
- App shell → Users: composes
- Users → Display board: renders
- Create user → User service: creates via
- Users → User service: lists via
- Client environment → User service: configures
- User service → Users API: HTTP user requests
- Container image → .NET project: packages
- Kubernetes deployment → Container image: runs image
- Kubernetes service → Kubernetes deployment: exposes
- Kubernetes manifest → Kubernetes deployment: includes
- Kubernetes manifest → Kubernetes service: includes