Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 .NET 10 + React Full-Stack Template

Auth wired. Docker ready. Just clone and build.

⚡ Quick Start

git clone https://github.com/YOUR_USERNAME/WebApiReact.git
cd WebApiReact
docker compose up --build
ServiceURL
Frontendhttp://localhost:3000 (Docker) / :5173 (dev)
APIhttp://localhost:5000
Swaggerhttp://localhost:5000/swagger
Healthhttp://localhost:5000/health

✅ Pre-Built

BackendFrontend
JWT Auth (register/login/refresh/me)Login/Register/Dashboard pages
Global exception middleware + traceIdProtected routes + auth guards
Request logging (method/path/status/duration/IP)Zustand auth state management
Serilog (console + daily file rotation)Axios with JWT auto-refresh on 401
EF Core auto-migrations on startupTailwind CSS v4 + reusable components
CORS, Health checks, Swagger, DockerTypeScript throughout

🏗️ Architecture

Frontend (:5173) — React 19 + Vite 6 + Tailwind v4
    │ HTTP (JWT Bearer)
Backend (:5000) — .NET 10 Clean Architecture
    │
    ├── API (Controllers + Middleware)
    ├── Application (Interfaces + DTOs)
    ├── Domain (Entities)
    └── Infrastructure (EF Core + JWT)
    │
Database (:1433) — MS SQL Server 2022

📁 Key Files

Backend/src/
├── API/
│   ├── Controllers/AuthController.cs     ← register, login, refresh, me
│   ├── Middleware/ExceptionMiddleware.cs  ← catches all → {status, detail, traceId}
│   ├── Middleware/RequestLoggingMiddleware.cs ← logs every request
│   └── Program.cs                         ← pipeline: Exception → Logging → CORS → Auth
├── Application/
│   ├── Interfaces/IApplicationDbContext.cs
│   ├── Interfaces/ITokenService.cs
│   └── DTOs/Auth/AuthDtos.cs
├── Domain/Entities/
│   ├── User.cs        ← IdentityUser<Guid> + ISoftDeletable
│   ├── Role.cs        ← IdentityRole<Guid>
│   └── UserRole.cs    ← join table
└── Infrastructure/
    ├── Data/ApplicationDbContext.cs
    ├── Authentication/JwtTokenService.cs  ← HS256, 15min access, refresh rotation
    └── Services/CurrentUserService.cs

Frontend/src/ ├── api/client.ts ← Axios + JWT interceptor + auto-refresh on 401 ├── store/authStore.ts ← Zustand: user, isAuthenticated, loading ├── components/ │ ├── Button.tsx, Input.tsx │ └── Layout.tsx ← Nav bar + Outlet ├── pages/ │ ├── Login.tsx, Register.tsx │ └── Dashboard.tsx └── App.tsx ← Router + ProtectedRoute + PublicRoute

🔧 How to Add Your Feature

  1. Add Entity → Backend/src/Domain/Entities/
  2. Add DTO → Backend/src/Application/DTOs/
  3. Add Controller → Backend/src/API/Controllers/
  4. Add Page → Frontend/src/pages/
  5. Add Route → Frontend/src/App.tsx
🤖 AI CONTEXT — Copy-paste this for any AI
=== FULL PROJECT CONTEXT: WebApiReact (.NET 10 + React 19) ===

BACKEND KEY FILES:

  • AuthController.cs: POST /api/auth/register, /login, /refresh, GET /api/auth/me
  • ExceptionMiddleware.cs: Catches all exceptions → {status, detail, traceId}
  • RequestLoggingMiddleware.cs: Logs method/path/status/duration/IP/user
  • Program.cs: Pipeline = ExceptionHandler → RequestLogging → CORS → Auth → Controllers
  • User.cs: IdentityUser<Guid> + FirstName, LastName, RefreshToken, RefreshTokenExpiry, Provider, IsActive, IsDeleted
  • ApplicationDbContext.cs: IdentityDbContext<User, Role, Guid>, soft-delete on User
  • JwtTokenService.cs: HS256, 15min access token, 64-byte refresh token, ValidateToken()

FRONTEND KEY FILES:

  • client.ts: Axios instance at VITE_API_URL (default http://localhost:5000), JWT interceptor + auto-refresh
  • authStore.ts: Zustand store (user, isAuthenticated, loading, login, register, logout, checkAuth)
  • App.tsx: BrowserRouter, ProtectedRoute (redirects /login), PublicRoute (redirects /)
  • Layout.tsx: Nav bar with user email + logout, <Outlet>

PACKAGES: Backend: MediatR, FluentValidation, EF Core SqlServer, Identity, JwtBearer, Serilog, Swagger, HealthChecks Frontend: react-router-dom, zustand, axios, tailwindcss v4, lucide-react, clsx, tailwind-merge

CONFIG: appsettings.json: ConnectionStrings:DefaultConnection (LocalDB), Jwt:Secret/Issuer/Audience .env: VITE_API_URL=http://localhost:5000 docker-compose.yml: sqlserver(:1433) + api(:5000→8080) + frontend(:3000→80)

ALREADY BUILT (DO NOT REBUILD): Auth endpoints, global exception handler, request logger, Serilog, auto-migrations, CORS, health checks, Swagger, Docker, protected routes, Zustand auth, Axios interceptors

MY REQUEST: [Describe your issue or feature here]

🐳 Docker

docker compose up --build
ServiceImagePort
Databasemssql/server:2022-latest1433
API.NET 10 ASP.NET5000
Frontendnginx:alpine3000

About

.NET 10 Web API + React TypeScript Full-Stack Template with JWT Auth, Clean Architecture, MS SQL Server

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages