/dotnet-crud-with-copilot

dotnet-crud-with-copilot

Primary LanguageC#

Fully Created with Copilot for .NET Core 8

This project demonstrates the power of Copilot in building a fully functional web application using .NET Core 8. It highlights simplicity, scalability, and modularity through a collection of features.

Fully created with Copilot including this Readme


Features

User Management

  • CRUD Operations:
    Fully implemented Create, Read, Update, and Delete functionalities for the User entity. These are built using minimal endpoints, without relying on controllers.

  • Search Functionality:
    Includes an endpoint to filter users by their Username. Supports partial matching for easy querying.


Data Validation

  • Custom Validation:
    Manual validation for the User model ensures clean and accurate data inputs. Since this is a web project and not a Web API, model validation attributes are avoided to keep things lightweight and simple.

Rate Limiting

  • Fixed Rate Limiter:
    Limits incoming requests globally to 1 request every 5 seconds per client. Utilizes the built-in .NET rate limiting system for seamless integration.

Visit Tracking Middleware

  • Path Visit Counter:
    Middleware counts how many times each endpoint (path) has been accessed.

  • RequestCounterService:
    Tracks visit counts and provides an interface for retrieving request statistics.

  • /visits Endpoint:
    A dedicated endpoint to retrieve a summary of all path visits as a JSON object.


Testing Made Simple

  • HTTP Requests File:
    requests.http file included to test all endpoints directly using tools like Visual Studio Code's REST Client or similar utilities.

Getting Started

Prerequisites

  • .NET SDK 8.0 or later.
  • A tool to run .http files (e.g., REST Client for VS Code or Postman).

Running the Project

  1. Clone the repository.
  2. Run the project:
   dotnet run

Endpoints Overview

User Endpoints

  • POST /users: Create a new user.
  • GET /users: Retrieve all users or filter them by username using the search query parameter.
  • GET /users/{id}: Retrieve a single user by ID.
  • PUT /users/{id}: Update an existing user's details.
  • DELETE /users/{id}: Remove a user by ID.

Path Visits Endpoint

  • GET /visits: Get a JSON summary of how many times each endpoint has been visited.

Built With

  • .NET Core 8
  • Copilot AI
  • REST Client / Postman (for testing)