This repository contains a full-stack application composed of a .NET API and a Next.js frontend.
- Middleware for global action/command handling
- Pre-processors for entity / behavior validation
- Controller attriute for entity exists / hash-check for if-match
- Contract / abstraction versioning via factory
- better test implementation (AI created)
- better logging (AI created)
- proper placement for XSS validation (AI added)
- more than smoke testing
- more robust or capable UI example
Before you begin, ensure you have the following installed:
- .NET SDK 8.0
- Node.js (LTS)
- npm (comes with Node.js)
- Docker Desktop
To get the entire application up and running quickly using Docker:
- Navigate to the
srcdirectory:cd src - Build and run the Docker containers:
This will start both the frontend and the API services.
docker-compose up --build
The frontend will typically be available at http://localhost:3000 and the API at http://localhost:5000 (or as configured in docker-compose.yml).
The frontend is a Next.js application.
Location: src/frontend
To run the frontend independently (without Docker):
- Navigate to the frontend directory:
cd src/frontend - Install dependencies:
npm install
- Run the development server:
The frontend will be available at
npm run dev
http://localhost:3000.
The API is a .NET 8.0 application.
Location: src/Stargate.Api
To run the API independently (without Docker):
- Navigate to the API directory:
cd src/Stargate.Api - Restore dependencies:
dotnet restore
- Run the application:
The API will be available at
dotnet run
http://localhost:5000(or as configured inProperties/launchSettings.json).
Deployment instructions will vary based on the target environment. For Docker-based deployments, the docker-compose.yml can serve as a starting point. Further configuration might be needed for production environments (e.g., reverse proxies, environment variables for database connections, etc.).
Unit and integration tests for the .NET projects are located in the src/Stargate.Tests directory.
To run all tests for the .NET projects:
dotnet test src/Stargate.TestsTest coverage reports are generated during the test run. After running tests, coverage results can usually be found within the TestResults or coveragereport directories under src/Stargate.Tests.
To generate a coverage report, you might need a tool like ReportGenerator or coverlet. For example, using coverlet and ReportGenerator:
- Install coverlet.collector in your test project:
dotnet add src/Stargate.Tests package coverlet.collector
- Run tests with coverage:
dotnet test src/Stargate.Tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - Install ReportGenerator global tool:
dotnet tool install -g dotnet-reportgenerator-globaltool
- Generate HTML report (adjust paths as necessary):
Open
reportgenerator -reports:"src/Stargate.Tests/coverage.opencover.xml" -targetdir:"src/Stargate.Tests/coveragereport" -reporttypes:Html
src/Stargate.Tests/coveragereport/index.htmlto view the report.
Here are some common Docker commands useful for this project:
- Build and run all services:
docker-compose up --build
- Start services in detached mode:
docker-compose up -d
- Stop and remove containers, networks, and volumes:
docker-compose down
- View logs for all services:
docker-compose logs -f
- View logs for a specific service (e.g.,
frontend):docker-compose logs -f frontend
- Execute a command inside a running service container (e.g., bash in
frontend):docker-compose exec frontend bash - List all running containers:
docker ps