13 Commits

Author SHA1 Message Date
KS Jannette
6f9a07798f axd-few-ref1274 2026-08-04 20:15:40 -04:00
88a8fdd14a Update README.md 2026-08-03 08:33:08 +00:00
0abba4c493 Update README.md 2026-08-03 08:32:30 +00:00
c6ad7c620f Update README.md 2026-08-03 08:32:13 +00:00
d55a006a40 Update README.md 2026-08-03 08:27:25 +00:00
fc7e2b7c2a Update README.md 2026-08-03 08:26:08 +00:00
691eae13fb Update README.md 2026-08-03 08:25:49 +00:00
df2bf0694b Merge pull request 'FEAT-buildout-endpoints' (#2) from FEAT-buildout-endpoints into master
Reviewed-on: #2
2026-08-03 08:24:32 +00:00
KS Jannette
ae77420753 Add to readme 2026-08-03 04:24:03 -04:00
KS Jannette
092ef17439 fleshout backend 2026-08-03 04:23:32 -04:00
a00282b1e6 Update README.md
Hot fix
2026-07-30 22:59:00 +00:00
ca8b322479 Merge pull request 'buildout full stack functionality' (#1) from FEAT-buildout into master
Reviewed-on: #1
2026-07-30 22:57:32 +00:00
KS Jannette
04a2910af5 buildout full stack functionality 2026-07-30 18:55:28 -04:00
38 changed files with 4265 additions and 51 deletions

74
AGENTS.md Normal file
View File

@@ -0,0 +1,74 @@
# AGENTS.md
Skeleton monorepo for React + .NET projects. Clone it, then replace the placeholder
`User` domain with the real one.
## Layout
```
backend/ ASP.NET Core Web API (net10.0)
frontend/ Vite + React + TypeScript SPA
```
## Running
| Stack | Command | URL |
| --- | --- | --- |
| Backend | `cd backend && dotnet run` | `http://localhost:5231` |
| Frontend | `cd frontend && npm install && npm run dev` | `http://localhost:3000` |
Start them in separate terminals. Allowed CORS origins live in `backend/appsettings.json`
under `Cors:AllowedOrigins`.
## Verifying changes
Run these before considering a change done:
```bash
cd backend && dotnet build
cd frontend && npm run build && npm run lint
```
## Backend conventions
- `ImplicitUsings` is enabled. Do not re-import `Microsoft.AspNetCore.*`,
`Microsoft.Extensions.DependencyInjection`, `System.Linq`, and friends.
- Use file-scoped namespaces (`namespace Backend.Data;`).
- Repository methods are async, suffixed `Async`, and take a `CancellationToken`.
- Read configuration through the options pattern (`IOptions<T>` + `Configure<T>`),
not `Configuration["Some:Key"]`.
- Controllers stay thin: validate, delegate to a repository or service, map the result
to an `IActionResult`. No data access in controllers.
- Route templates use `ApiRoutes.V1` rather than a hardcoded `"v1"` string.
- Cross-cutting pipeline concerns (CORS, rate limiting) belong in `backend/Gateway/`
and are wired through `AddApiGateway` / `UseApiGateway`, not inline in `Program.cs`.
- Persistence implementations register through `AddPersistence`, selected by the
`Persistence:Provider` setting. Swapping in EF Core or another store should not
require touching controllers.
## Frontend conventions
- All HTTP goes through `src/api/`. Components never call `fetch` directly.
- Configuration comes from `VITE_*` environment variables; `VITE_API_BASE_URL` points
at the backend. Add new variables to `.env.example` and to the `ImportMetaEnv`
interface in `src/vite-env.d.ts`.
- TypeScript is strict and unused locals are errors. The build runs `tsc -b` before Vite.
## Endpoints
| Method | Path | Purpose |
| --- | --- | --- |
| GET | `/health` | Liveness check, unversioned for infrastructure |
| GET | `/v1/info` | App name, version, environment, server timestamp |
| GET | `/v1/users` | List users |
| GET | `/v1/users/{id}` | Fetch one user |
| POST | `/v1/users` | Create a user |
| PUT | `/v1/users/{id}` | Replace a user |
| DELETE | `/v1/users/{id}` | Delete a user |
Sample requests live in `backend/backend.http`.
## Not included on purpose
Authentication, a real database provider, tests, Docker, and structured logging are all
left out. Add them when the project has requirements that justify a specific choice.

View File

@@ -1,2 +1,73 @@
# react-dotnet # React-Dotnet Framework
Once upon a time, people maintinaed "skeleton" repos they could clone to quickly jumpstart new projects. Why? It was quick, free and it worked.
### A. Always. B. Be. C. Consciously TokenWoxxxening
### This is a full-stask project jumpstarter with:git status
### .NET backend
### React/Vite frontend
# .Net
Five CRUD endpoints return correct status codes:
201 with a proper Location header
400 on invalid email, 409 on duplicate, 204 then 404 on delete), 150 requests to /v1/info yielded exactly 100 successes and the rest 429, and 40 requests to /health all returned 200 while that window was exhausted.
## Prerequisites
- [.NET SDK](https://dotnet.microsoft.com/download) (project targets `net10.0`)
- [Node.js](https://nodejs.org/) (LTS recommended)
## Backend
From the repository root:
```bash
cd backend
dotnet run
```
The API runs at `http://localhost:5231`. Swagger UI is available in Development at `http://localhost:5231/swagger`.
Skeleton endpoints:
- `GET /health` — liveness check, exempt from rate limiting
- `GET /v1/info` — app name, version, environment, and server timestamp
- `GET|POST /v1/users`, `GET|PUT|DELETE /v1/users/{id}` — placeholder CRUD over the
in-memory repository
Requests are rate limited per client IP using the `RateLimiting` section of
`appsettings.json`, and allowed CORS origins come from the `Cors` section. Storage is
selected by `Persistence:Provider`, which currently supports `InMemory` only; data is
lost on restart until a real provider is registered in
`backend/Data/PersistenceServiceCollectionExtensions.cs`.
## Frontend
From the repository root:
```bash
cd frontend
npm install
npm run dev
```
The app runs at `http://localhost:3000`.
Copy `.env.example` to `.env.development` (or `.env.local`) if you need to customize the API URL:
```
VITE_API_BASE_URL=http://localhost:5231
```
## Running both
Start the backend and frontend in separate terminals. The backend CORS policy allows requests from `http://localhost:3000` by default; change `Cors:AllowedOrigins` in `backend/appsettings.json` to add more.
## Project structure
```
backend/ ASP.NET Core Web API
frontend/ React + Vite + TypeScript SPA
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

View File

@@ -0,0 +1,30 @@
using Backend.Gateway;
using Microsoft.AspNetCore.Mvc;
namespace Backend.Controllers;
[ApiController]
[Route(ApiRoutes.V1 + "/[controller]")]
public sealed class InfoController : ControllerBase
{
private readonly IWebHostEnvironment _environment;
public InfoController(IWebHostEnvironment environment)
{
_environment = environment;
}
[HttpGet]
public IActionResult Get()
{
var assembly = typeof(InfoController).Assembly.GetName();
return Ok(new
{
name = assembly.Name ?? "backend",
version = assembly.Version?.ToString(3) ?? "0.0.0",
environment = _environment.EnvironmentName,
timestamp = DateTime.UtcNow,
});
}
}

View File

@@ -1,17 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Backend.Data;
namespace Backend.Controllers
{
[Route("v1/[controller]")]
[ApiController]
public class UserController : ControllerBase
{
private readonly IUserRepository _userRepository;
public UserController(IUserRepository userRepository)
{
_userRepository = userRepository;
}
}
}

View File

@@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace Backend.Controllers;
// Validation attributes must target the primary constructor parameters, not the
// generated properties; MVC rejects record types with property-level metadata.
public sealed record CreateUserRequest(
[Required][EmailAddress] string Email,
[Required][StringLength(100, MinimumLength = 1)] string DisplayName);
public sealed record UpdateUserRequest(
[Required][EmailAddress] string Email,
[Required][StringLength(100, MinimumLength = 1)] string DisplayName);

View File

@@ -0,0 +1,96 @@
using Backend.Data;
using Backend.Gateway;
using Microsoft.AspNetCore.Mvc;
namespace Backend.Controllers;
[ApiController]
[Route(ApiRoutes.V1 + "/[controller]")]
public sealed class UsersController : ControllerBase
{
private readonly IUserRepository _userRepository;
public UsersController(IUserRepository userRepository)
{
_userRepository = userRepository;
}
[HttpGet]
[ProducesResponseType<IReadOnlyList<User>>(StatusCodes.Status200OK)]
public async Task<IActionResult> GetAll(CancellationToken cancellationToken)
=> Ok(await _userRepository.GetAllAsync(cancellationToken));
[HttpGet("{id:guid}")]
[ProducesResponseType<User>(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetById(Guid id, CancellationToken cancellationToken)
{
var user = await _userRepository.GetByIdAsync(id, cancellationToken);
return user is null ? NotFound() : Ok(user);
}
[HttpPost]
[ProducesResponseType<User>(StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
public async Task<IActionResult> Create(
CreateUserRequest request,
CancellationToken cancellationToken)
{
if (await _userRepository.GetByEmailAsync(request.Email, cancellationToken) is not null)
{
return Conflict(new ProblemDetails
{
Title = "Email already in use",
Status = StatusCodes.Status409Conflict,
});
}
var user = await _userRepository.AddAsync(
new User { Email = request.Email, DisplayName = request.DisplayName },
cancellationToken);
return CreatedAtAction(nameof(GetById), new { id = user.Id }, user);
}
[HttpPut("{id:guid}")]
[ProducesResponseType<User>(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
public async Task<IActionResult> Update(
Guid id,
UpdateUserRequest request,
CancellationToken cancellationToken)
{
var existing = await _userRepository.GetByIdAsync(id, cancellationToken);
if (existing is null)
{
return NotFound();
}
var emailOwner = await _userRepository.GetByEmailAsync(request.Email, cancellationToken);
if (emailOwner is not null && emailOwner.Id != id)
{
return Conflict(new ProblemDetails
{
Title = "Email already in use",
Status = StatusCodes.Status409Conflict,
});
}
existing.Email = request.Email;
existing.DisplayName = request.DisplayName;
var updated = await _userRepository.UpdateAsync(existing, cancellationToken);
return updated is null ? NotFound() : Ok(updated);
}
[HttpDelete("{id:guid}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> Delete(Guid id, CancellationToken cancellationToken)
=> await _userRepository.DeleteAsync(id, cancellationToken) ? NoContent() : NotFound();
}

View File

@@ -1,5 +1,22 @@
namespace Backend.Data; namespace Backend.Data;
/// <summary>
/// Storage-agnostic access to <see cref="User"/>. Implementations are selected by the
/// <c>Persistence:Provider</c> setting; see <see cref="PersistenceServiceCollectionExtensions"/>.
/// </summary>
public interface IUserRepository public interface IUserRepository
{ {
Task<IReadOnlyList<User>> GetAllAsync(CancellationToken cancellationToken = default);
Task<User?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default);
Task<User?> GetByEmailAsync(string email, CancellationToken cancellationToken = default);
Task<User> AddAsync(User user, CancellationToken cancellationToken = default);
/// <returns>The updated user, or <c>null</c> when no user has the given id.</returns>
Task<User?> UpdateAsync(User user, CancellationToken cancellationToken = default);
/// <returns><c>true</c> when a user was removed.</returns>
Task<bool> DeleteAsync(Guid id, CancellationToken cancellationToken = default);
} }

View File

@@ -0,0 +1,58 @@
using System.Collections.Concurrent;
namespace Backend.Data.InMemory;
/// <summary>
/// Default implementation so the skeleton runs with no database. State is per-process
/// and lost on restart.
/// </summary>
public sealed class InMemoryUserRepository : IUserRepository
{
private readonly ConcurrentDictionary<Guid, User> _users = new();
public Task<IReadOnlyList<User>> GetAllAsync(CancellationToken cancellationToken = default)
{
IReadOnlyList<User> users = _users.Values
.OrderBy(user => user.CreatedAt)
.ToList();
return Task.FromResult(users);
}
public Task<User?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default)
{
_users.TryGetValue(id, out var user);
return Task.FromResult(user);
}
public Task<User?> GetByEmailAsync(string email, CancellationToken cancellationToken = default)
{
var user = _users.Values
.FirstOrDefault(candidate => string.Equals(candidate.Email, email, StringComparison.OrdinalIgnoreCase));
return Task.FromResult(user);
}
public Task<User> AddAsync(User user, CancellationToken cancellationToken = default)
{
_users[user.Id] = user;
return Task.FromResult(user);
}
public Task<User?> UpdateAsync(User user, CancellationToken cancellationToken = default)
{
if (!_users.ContainsKey(user.Id))
{
return Task.FromResult<User?>(null);
}
_users[user.Id] = user;
return Task.FromResult<User?>(user);
}
public Task<bool> DeleteAsync(Guid id, CancellationToken cancellationToken = default)
=> Task.FromResult(_users.TryRemove(id, out _));
}

View File

@@ -0,0 +1,13 @@
namespace Backend.Data;
public sealed class PersistenceOptions
{
public const string SectionName = "Persistence";
public string Provider { get; set; } = PersistenceProviders.InMemory;
}
public static class PersistenceProviders
{
public const string InMemory = "InMemory";
}

View File

@@ -0,0 +1,37 @@
using Backend.Data.InMemory;
namespace Backend.Data;
/// <summary>
/// Single place where a storage backend is chosen. To add a real database, implement
/// <see cref="IUserRepository"/> and register it under a new provider name here;
/// controllers stay untouched.
/// </summary>
public static class PersistenceServiceCollectionExtensions
{
public static IServiceCollection AddPersistence(
this IServiceCollection services,
IConfiguration configuration)
{
services.Configure<PersistenceOptions>(configuration.GetSection(PersistenceOptions.SectionName));
var provider = configuration.GetSection(PersistenceOptions.SectionName).Get<PersistenceOptions>()?.Provider
?? PersistenceProviders.InMemory;
switch (provider)
{
case PersistenceProviders.InMemory:
// Singleton because the store itself holds the data.
services.AddSingleton<IUserRepository, InMemoryUserRepository>();
break;
default:
throw new InvalidOperationException(
$"Unknown persistence provider '{provider}'. Supported providers: " +
$"'{PersistenceProviders.InMemory}'. Register additional providers in " +
$"{nameof(PersistenceServiceCollectionExtensions)}.");
}
return services;
}
}

15
backend/Data/User.cs Normal file
View File

@@ -0,0 +1,15 @@
namespace Backend.Data;
/// <summary>
/// Placeholder domain entity. Replace with the real model once the project has one.
/// </summary>
public sealed class User
{
public Guid Id { get; init; } = Guid.NewGuid();
public required string Email { get; set; }
public required string DisplayName { get; set; }
public DateTime CreatedAt { get; init; } = DateTime.UtcNow;
}

View File

@@ -0,0 +1,8 @@
namespace Backend.Gateway;
public static class ApiRoutes
{
public const string V1 = "v1";
public const string Health = "/health";
}

View File

@@ -0,0 +1,14 @@
namespace Backend.Gateway;
public static class GatewayApplicationBuilderExtensions
{
// CORS must run before the rate limiter so that rejected requests still carry
// the headers the browser needs to surface a 429 to the client.
public static IApplicationBuilder UseApiGateway(this IApplicationBuilder app)
{
app.UseCors(GatewayServiceCollectionExtensions.CorsPolicyName);
app.UseRateLimiter();
return app;
}
}

View File

@@ -0,0 +1,19 @@
namespace Backend.Gateway;
public sealed class CorsOptions
{
public const string SectionName = "Cors";
public string[] AllowedOrigins { get; set; } = [];
}
public sealed class RateLimitOptions
{
public const string SectionName = "RateLimiting";
public int PermitLimit { get; set; } = 100;
public int WindowSeconds { get; set; } = 60;
public int QueueLimit { get; set; }
}

View File

@@ -0,0 +1,64 @@
using System.Threading.RateLimiting;
using Microsoft.AspNetCore.RateLimiting;
namespace Backend.Gateway;
public static class GatewayServiceCollectionExtensions
{
public const string CorsPolicyName = "DefaultCorsPolicy";
public static IServiceCollection AddApiGateway(
this IServiceCollection services,
IConfiguration configuration)
{
services.Configure<CorsOptions>(configuration.GetSection(CorsOptions.SectionName));
services.Configure<RateLimitOptions>(configuration.GetSection(RateLimitOptions.SectionName));
var corsSettings = configuration.GetSection(CorsOptions.SectionName).Get<CorsOptions>()
?? new CorsOptions();
var rateLimitSettings = configuration.GetSection(RateLimitOptions.SectionName).Get<RateLimitOptions>()
?? new RateLimitOptions();
services.AddCors(options => options.AddPolicy(CorsPolicyName, policy =>
{
if (corsSettings.AllowedOrigins.Length == 0)
{
return;
}
policy.WithOrigins(corsSettings.AllowedOrigins)
.AllowAnyHeader()
.AllowAnyMethod();
}));
services.AddRateLimiter(options =>
{
options.RejectionStatusCode = StatusCodes.Status429TooManyRequests;
options.GlobalLimiter = CreateGlobalLimiter(rateLimitSettings);
});
services.Configure<RouteOptions>(options => options.LowercaseUrls = true);
return services;
}
// Health checks are exempt so that infrastructure probes are never throttled.
private static PartitionedRateLimiter<HttpContext> CreateGlobalLimiter(RateLimitOptions settings) =>
PartitionedRateLimiter.Create<HttpContext, string>(context =>
{
if (context.Request.Path.StartsWithSegments(ApiRoutes.Health))
{
return RateLimitPartition.GetNoLimiter("health");
}
var partitionKey = context.Connection.RemoteIpAddress?.ToString() ?? "unknown";
return RateLimitPartition.GetFixedWindowLimiter(partitionKey, _ => new FixedWindowRateLimiterOptions
{
PermitLimit = settings.PermitLimit,
Window = TimeSpan.FromSeconds(settings.WindowSeconds),
QueueLimit = settings.QueueLimit,
QueueProcessingOrder = QueueProcessingOrder.OldestFirst,
});
});
}

View File

@@ -1,36 +1,46 @@
using Microsoft.AspNetCore.Builder; using System.Text.Json;
using Microsoft.AspNetCore.Mvc; using Backend.Data;
using Microsoft.EntityFrameworkCore; using Backend.Gateway;
using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
// using Backend.Data using Microsoft.Extensions.Diagnostics.HealthChecks;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers(); builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen();
builder.Services.AddHealthChecks();
builder.Services.AddProblemDetails();
builder.Services.AddCors(); builder.Services.AddApiGateway(builder.Configuration);
builder.Services.AddPersistence(builder.Configuration);
//builder.Services.AddDbContext<UserContext>(options =>
// options.UseSqlite(builder.Configuration["ConnectionStrings:UserConnection"])
//);
//builder.Services.AddScoped<IBowlingLeagueRepository, EFBowlingLeagueRepository>();
var app = builder.Build(); var app = builder.Build();
// Configure the HTTP request pipeline. app.UseExceptionHandler();
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(); app.UseSwaggerUI();
} }
app.UseCors(p => p.WithOrigins("http://localhost:3000"));
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseAuthorization(); app.UseApiGateway();
app.MapHealthChecks(ApiRoutes.Health, new HealthCheckOptions
{
ResponseWriter = async (context, report) =>
{
context.Response.ContentType = "application/json";
var payload = JsonSerializer.Serialize(new
{
status = report.Status == HealthStatus.Healthy ? "healthy" : "unhealthy",
});
await context.Response.WriteAsync(payload);
},
});
app.MapControllers(); app.MapControllers();

View File

@@ -6,7 +6,17 @@
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"ConnectionStrings": { "Cors": {
"BowlingLeagueConnection": "Data Source=BowlingLeague.sqlite" "AllowedOrigins": [
"http://localhost:3000"
]
},
"RateLimiting": {
"PermitLimit": 100,
"WindowSeconds": 60,
"QueueLimit": 0
},
"Persistence": {
"Provider": "InMemory"
} }
} }

View File

@@ -7,16 +7,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup> </ItemGroup>

View File

@@ -1,6 +1,46 @@
@Backend_HostAddress = http://localhost:3000 @Backend_HostAddress = http://localhost:5231
@UserId = 00000000-0000-0000-0000-000000000000
GET {{Backend_HostAddress}}/weatherforecast/ GET {{Backend_HostAddress}}/health
Accept: application/json Accept: application/json
### ###
GET {{Backend_HostAddress}}/v1/info
Accept: application/json
###
GET {{Backend_HostAddress}}/v1/users
Accept: application/json
###
POST {{Backend_HostAddress}}/v1/users
Content-Type: application/json
{
"email": "ada@example.com",
"displayName": "Ada Lovelace"
}
###
GET {{Backend_HostAddress}}/v1/users/{{UserId}}
Accept: application/json
###
PUT {{Backend_HostAddress}}/v1/users/{{UserId}}
Content-Type: application/json
{
"email": "ada@example.com",
"displayName": "Ada King"
}
###
DELETE {{Backend_HostAddress}}/v1/users/{{UserId}}
###

View File

@@ -0,0 +1 @@
VITE_API_BASE_URL=http://localhost:5231

1
frontend/.env.example Normal file
View File

@@ -0,0 +1 @@
VITE_API_BASE_URL=http://localhost:5231

24
frontend/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

28
frontend/eslint.config.js Normal file
View File

@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2022,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)

13
frontend/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>React + .NET Starter</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

3258
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

29
frontend/package.json Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
"devDependencies": {
"@eslint/js": "^9.30.1",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"@vitejs/plugin-react": "^4.6.0",
"eslint": "^9.30.1",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.3.0",
"typescript": "~5.8.3",
"typescript-eslint": "^8.35.1",
"vite": "^7.0.4"
}
}

1
frontend/public/vite.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFBD4F"></stop><stop offset="100%" stop-color="#FF980E"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

89
frontend/src/App.css Normal file
View File

@@ -0,0 +1,89 @@
.app {
max-width: 720px;
margin: 0 auto;
padding: 3rem 1.5rem;
}
.app__header {
margin-bottom: 2rem;
}
.app__header h1 {
margin: 0 0 0.5rem;
font-size: 2rem;
font-weight: 600;
}
.app__header p {
margin: 0;
color: #64748b;
}
.app__section {
padding: 1.25rem 1.5rem;
border: 1px solid #e2e8f0;
border-radius: 8px;
background-color: #f8fafc;
}
.app__section h2 {
margin: 0 0 0.75rem;
font-size: 1.125rem;
font-weight: 600;
}
.app__section p {
margin: 0;
color: #475569;
}
.app__section code {
font-size: 0.875em;
background-color: #e2e8f0;
padding: 0.125rem 0.375rem;
border-radius: 4px;
}
.app__section--api {
margin-top: 1rem;
}
.app__status {
margin: 0.75rem 0 0;
font-weight: 500;
}
.app__status--loading {
color: #64748b;
}
.app__status--ok {
color: #15803d;
}
.app__status--error {
color: #b91c1c;
}
.app__info {
display: grid;
gap: 0.75rem;
margin: 1rem 0 0;
}
.app__info div {
display: grid;
grid-template-columns: 8rem 1fr;
gap: 0.5rem;
}
.app__info dt {
margin: 0;
color: #64748b;
font-weight: 500;
}
.app__info dd {
margin: 0;
color: #334155;
}

83
frontend/src/App.tsx Normal file
View File

@@ -0,0 +1,83 @@
import { useEffect, useState } from 'react'
import { apiBaseUrl, apiFetch } from './api/client'
import './App.css'
type InfoResponse = {
name: string
version: string
environment: string
timestamp: string
}
function App() {
const [info, setInfo] = useState<InfoResponse | null>(null)
const [error, setError] = useState<string | null>(null)
const [loading, setLoading] = useState(true)
useEffect(() => {
apiFetch<InfoResponse>('/v1/info')
.then(setInfo)
.catch((err: unknown) =>
setError(err instanceof Error ? err.message : 'Unknown error'),
)
.finally(() => setLoading(false))
}, [])
return (
<div className="app">
<header className="app__header">
<h1>React + .NET Starter</h1>
<p>A minimal monorepo skeleton for new projects.</p>
</header>
<section className="app__section">
<h2>Frontend</h2>
<p>
Vite + React + TypeScript running on port 3000. Extend{' '}
<code>src/App.tsx</code> to begin building your application.
</p>
</section>
<section className="app__section app__section--api">
<h2>Backend API</h2>
<p>
Requests go to <code>{apiBaseUrl}</code> via{' '}
<code>VITE_API_BASE_URL</code>.
</p>
{loading && <p className="app__status app__status--loading">Checking API…</p>}
{error && (
<p className="app__status app__status--error">
Unable to reach API: {error}
</p>
)}
{info && (
<dl className="app__info">
<div>
<dt>Status</dt>
<dd className="app__status app__status--ok">Connected</dd>
</div>
<div>
<dt>Name</dt>
<dd>{info.name}</dd>
</div>
<div>
<dt>Version</dt>
<dd>{info.version}</dd>
</div>
<div>
<dt>Environment</dt>
<dd>{info.environment}</dd>
</div>
<div>
<dt>Server time (UTC)</dt>
<dd>{new Date(info.timestamp).toISOString()}</dd>
</div>
</dl>
)}
</section>
</div>
)
}
export default App

View File

@@ -0,0 +1,17 @@
const baseUrl = import.meta.env.VITE_API_BASE_URL
export async function apiFetch<T>(
path: string,
init?: RequestInit,
): Promise<T> {
const url = `${baseUrl}${path.startsWith('/') ? path : `/${path}`}`
const response = await fetch(url, init)
if (!response.ok) {
throw new Error(`API request failed: ${response.status} ${response.statusText}`)
}
return response.json() as Promise<T>
}
export { baseUrl as apiBaseUrl }

28
frontend/src/index.css Normal file
View File

@@ -0,0 +1,28 @@
:root {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
sans-serif;
line-height: 1.5;
font-weight: 400;
color: #213547;
background-color: #ffffff;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
margin: 0;
min-width: 320px;
min-height: 100vh;
}
#root {
min-height: 100vh;
}

10
frontend/src/main.tsx Normal file
View File

@@ -0,0 +1,10 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)

9
frontend/src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_API_BASE_URL: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}

7
frontend/tsconfig.json Normal file
View File

@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}

View File

@@ -0,0 +1,21 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}

10
frontend/vite.config.ts Normal file
View File

@@ -0,0 +1,10 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
host: 'localhost',
},
})