https://github.com/rashedul-alam46/library-api-sqlserver
REST API built with .NET, C#, and MS SQL Server
https://github.com/rashedul-alam46/library-api-sqlserver
csharp dotnet-core restful-api sql-server
Last synced: about 3 hours ago
JSON representation
REST API built with .NET, C#, and MS SQL Server
- Host: GitHub
- URL: https://github.com/rashedul-alam46/library-api-sqlserver
- Owner: rashedul-alam46
- Created: 2025-09-25T11:57:22.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-11-04T15:56:58.000Z (8 months ago)
- Last Synced: 2026-04-01T09:31:57.179Z (3 months ago)
- Topics: csharp, dotnet-core, restful-api, sql-server
- Language: C#
- Homepage:
- Size: 7.09 MB
- Stars: 6
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Library API (SQL Server + Docker)
A .NET Core / .NET 9 Web API for managing a library system, backed by MS SQL Server.
This project is structured with clean architecture (Domain, Application, Infrastructure, API) and supports basic CRUD operations on books, authors, categories, publishers, etc.
---
## π Repository Structure
```
LibraryApiSqlServer/
βββ Library.Api/ # API / presentation layer (controllers, endpoints)
βββ Library.Application/ # Application logic
β βββ Services/ # Business services / use cases
β βββ DTOs/ # Data Transfer Objects, ViewModels
βββ Library.Domain/ # Domain / core (entities, interfaces)
βββ Library.Infrastructure/ # Data access, repository implementations, EF Core, DB context
βββ LibraryApiSqlServer.sln
βββ Program.cs
βββ appsettings.json
βββ appsettings.Development.json
βββ README.md
```
---
## βοΈ Prerequisites
- [.NET 9 SDK](https://dotnet.microsoft.com/download) or compatible .NET version
- SQL Server instance (local or remote)
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) for containerized setup (Optional)
- A tool like **SQL Server Management Studio (SSMS)** for DB inspection (Optional)
---
## π§ Setup / Getting Started
**1. Clone the repository**
```bash
git clone https://github.com/rashedulalam46/library-api-sqlserver.git
cd library-api-sqlserver
```
**2. Configure connection string**
Open appsettings.json or appsettings.Development.json, and set up your ConnectionStrings:DefaultConnection to point to your SQL Server.
```
{
"ConnectionStrings": {
"ConString": "Server=YOUR_SERVER;Database=LibraryDb;User Id=β¦;Password=β¦;"
}
}
```
If you are using Docker, then use
```
{
"ConnectionStrings": {
"ConString": "Server=host.docker.internal;Database=LibraryDb;User Id=β¦;Password=β¦;"
}
}
```
**3. Apply migrations / create database**
Run the SQL script located in **Library.Infrastructure/Data/DatabaseScript.sql** to create the database and tables.
Alternatively, to create the database and tables using Entity Framework, run the following command in the Infrastructure project (or from the solution root):
```
dotnet ef database update
```
This will create the database and necessary tables.
**4. Build & run the API**
```
dotnet build
dotnet run
```
The default launch URL might be https://localhost:5001 (or as configured). Use a tool like Postman, curl, or HTTPie to test the endpoints.
## π£οΈ API Endpoints (Examples)
These are sample endpoints β adjust according to actual implementation.
| Method | URL | Description |
| ------ | --------------- | ----------------------- |
| GET | /api/books | Get all books |
| GET | /api/books/{id} | Get book by ID |
| POST | /api/books | Create a new book |
| PUT | /api/books/{id} | Update an existing book |
| DELETE | /api/books/{id} | Delete a book by ID |
## β
Features & Highlights
- Clean / layered architecture (Domain, Application, Infrastructure)
- Dependency Injection
- EF Core as data access layer
- DTOs / ViewModels for input/output
- Configuration-based connection strings
- Exception handling, validation, etc. (if implemented)
## π¦ Deployment
When youβre ready to deploy:
- Configure the production connection string in environment variables.
- Publish the project:
```
dotnet publish --configuration Release
```
- Deploy the resulting output to your server / host / container.
- Ensure the database is accessible and migrations are applied.
## π License & Contribution
- Feel free to fork or suggest changes via pull requests.
- Add a LICENSE file if you have specific usage terms.
- Please document style, code conventions, etc., in a CONTRIBUTING.md.