Skip to content

thebrownproject/csharp-api-project

Repository files navigation

Veterinary Management API

A modern ASP.NET Core 9.0 web application demonstrating clean architecture patterns with Supabase integration

.NET ASP.NET Core Supabase C# Swagger

πŸš€ Overview

This project showcases modern .NET development practices through a veterinary contact management system. Built with ASP.NET Core 9.0 and Supabase, it demonstrates clean architecture principles, RESTful API design, and real-time database integration.

Key Technical Features

  • Clean Architecture: Separation of concerns with distinct layers for Controllers, Models, and Contracts
  • Modern .NET: Built on .NET 9.0 with latest C# 12 features
  • Cloud Database: Real-time integration with Supabase PostgreSQL
  • API Documentation: Interactive Swagger/OpenAPI documentation
  • Dependency Injection: Leverages ASP.NET Core's built-in DI container
  • JSON Handling: Advanced serialization with Newtonsoft.Json

πŸ“ Project Structure

β”œβ”€β”€ Controllers/          # API endpoints and business logic
β”‚   β”œβ”€β”€ VetController.cs     # CRUD operations for veterinarians
β”‚   └── ControllerBoilerplate.cs # Template for new controllers
β”œβ”€β”€ Models/              # Database entity mappings
β”‚   β”œβ”€β”€ VetModel.cs         # Supabase table mapping
β”‚   └── HealthCheckModel.cs # System health monitoring
β”œβ”€β”€ Contracts/           # Data Transfer Objects (DTOs)
β”‚   └── CreateVetRequest.cs # API request validation models
β”œβ”€β”€ Pages/               # Razor Pages UI (optional frontend)
└── Program.cs           # Application entry point & configuration

πŸ› οΈ Technical Architecture

Database Layer

  • Supabase Integration: Direct PostgreSQL connection with real-time capabilities
  • Entity Mapping: Automatic table-to-class mapping with attributes
  • Type Safety: Strongly-typed database operations

API Layer

  • RESTful Design: Standard HTTP methods with proper status codes
  • Input Validation: Request DTOs separate from database models
  • Error Handling: Comprehensive exception management
  • Documentation: Auto-generated API documentation

Configuration

  • Environment-based Settings: Separate configs for development/production
  • Secure Credentials: Configuration-based connection strings
  • Flexible Deployment: Easy environment switching

πŸ“‹ API Endpoints

Veterinarian Management

Method Endpoint Description Request Body
POST /vet/{id} Create new veterinarian CreateVetRequest
GET /vet/{id} Get veterinarian by ID -
PUT /vet/{id} Update veterinarian UpdateVetRequest (planned)
DELETE /vet/{id} Delete veterinarian - (planned)

Sample Request Body

{
  "title": "Dr.",
  "firstName": "John",
  "lastName": "Smith", 
  "email": "john.smith@vetclinic.com",
  "phone": "+1234567890",
  "clinicName": "Downtown Veterinary Clinic",
  "clinicAddress": "123 Main St, City, State 12345"
}

🚦 Getting Started

Prerequisites

Local Setup

  1. Clone the repository

    git clone <repository-url>
    cd min-api-project
  2. Configure Supabase

    # Create appsettings.Development.json
    {
      "SupabaseUrl": "your-supabase-project-url",
      "SupabaseApiKey": "your-supabase-anon-key",
      "UseSwagger": true,
      "DetailedErrors": true
    }
  3. Install dependencies

    dotnet restore
  4. Run the application

    # HTTP (recommended for development)
    dotnet run --launch-profile http
    
    # HTTPS 
    dotnet run --launch-profile https
  5. Access the application

πŸ—„οΈ Database Schema

Veterinarian Table Structure

CREATE TABLE vet (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    title VARCHAR(10),
    first_name VARCHAR(100) NOT NULL,
    last_name VARCHAR(100) NOT NULL,
    email VARCHAR(255) UNIQUE,
    phone VARCHAR(20) NOT NULL,
    clinic_name VARCHAR(200),
    clinic_address TEXT,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

πŸ”§ Development Commands

# Build the project
dotnet build

# Run with specific profile
dotnet run --launch-profile http    # Port 5144
dotnet run --launch-profile https   # Port 7020

# Add new packages
dotnet add package [PackageName]

# Restore dependencies
dotnet restore

🌟 Technical Highlights

Clean Code Practices

  • Separation of Concerns: Clear distinction between data models, request DTOs, and business logic
  • Dependency Injection: Leverages ASP.NET Core's built-in container for loose coupling
  • Configuration Management: Environment-based settings with validation
  • Error Handling: Proper HTTP status codes and exception management

Modern .NET Features

  • Minimal APIs: Lightweight, performance-focused endpoints
  • Record Types: Immutable data structures where applicable
  • Nullable Reference Types: Enhanced type safety
  • Global Using Statements: Reduced code verbosity

Database Integration

  • Real-time Capabilities: Supabase real-time subscriptions enabled
  • Automatic Refresh: Token management handled automatically
  • Type-safe Queries: Strongly-typed database operations
  • Migration Support: Schema versioning through Supabase dashboard

πŸš€ Future Enhancements

  • Complete CRUD operations (Update, Delete)
  • Authentication and authorization with JWT
  • Unit and integration testing
  • Docker containerization
  • CI/CD pipeline setup
  • Rate limiting and API versioning
  • Logging and monitoring integration
  • Performance optimization and caching

πŸ›‘οΈ Security Features

  • Configuration-based secret management
  • Input validation and sanitization
  • SQL injection protection through ORM
  • HTTPS redirection in production
  • CORS configuration for cross-origin requests

πŸ“Š Performance Considerations

  • Async/await patterns for non-blocking I/O
  • Connection pooling through dependency injection
  • JSON serialization optimizations
  • Lazy loading where applicable

This project demonstrates proficiency in modern .NET development, cloud database integration, and RESTful API design principles. Built as a portfolio piece to showcase full-stack development capabilities.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •