Skip to content

bhavikpatel99/Web.Api

Repository files navigation

SaaS-Based Multi-Tenant API in .NET Core

🚀 Overview

This project is a SaaS-based API built using .NET Core, implementing multi-tenancy with row-level security. It provides Tenant Management and User CRUD operations, ensuring secure data access per tenant.

📌 Features

  • Multi-Tenant Architecture
  • Row-Level Security using TenantId
  • CRUD operations for Users
  • Middleware for Exception Handling & Request Logging
  • Uses Stored Procedures for Database Access

🏗️ Project Structure

WebApi.Solution
│-- WebApi                  # API Project
│-- WebApi.Common           # Common Utilities
│-- WebApi.Entity           # Entity Models
│-- WebApi.Repository       # Data Access Layer
│-- WebApi.Service          # Business Logic Layer
│-- WebApi.Middleware       # Middleware for Logging & Exception Handling

⚡ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/yourusername/your-repo.git
cd your-repo

2️⃣ Configure Database Connection

Update appsettings.json with your database connection string:

"ConnectionStrings": {
  "DefaultConnection": "Server=your_server;Database=your_db;User Id=your_user;Password=your_password;"
}

3️⃣ Run Database Migrations (If Applicable)

dotnet ef database update

4️⃣ Run the API

dotnet run --project WebApi

🛠️ API Endpoints

Tenant Management

Create a Tenant

POST /api/tenant/create

Request:

{
  "name": "Company A"
}

User Management

Create a User

POST /api/user/create

Request:

{
  "name": "John Doe",
  "email": "[email protected]",
  "tenantId": "550e8400-e29b-41d4-a716-446655440000"
}

Get Users by Tenant

GET /api/user/{tenantId}

Update a User

PUT /api/user/update/{id}

Delete a User

DELETE /api/user/delete/{id}

🔧 Technologies Used

  • .NET Core 8.0
  • Entity Framework Core
  • SQL Server (Stored Procedures)
  • Middleware for Logging & Security
  • Swagger (API Documentation)

📜 License

This project is licensed under the MIT License.

🤝 Contributing

  1. Fork the repository 🍴
  2. Create a new branch 📂 (git checkout -b feature-branch)
  3. Commit your changes ✅ (git commit -m 'Added new feature')
  4. Push the branch 🚀 (git push origin feature-branch)
  5. Create a Pull Request 🔄

🔹 Author: Bhavik Patel
🔹 GitHub: bhavikpatel99
🔹 Email: [email protected]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages