A lightweight and efficient RESTful API backend built using ASP.NET Core and Entity Framework Core with SQLite, designed to support a Library Management System.
This backend handles:
- 📚 Book CRUD operations
- 🔐 User Authentication (JWT-based)
- 🗄 SQLite database with Entity Framework
- 🌐 API endpoints for frontend integration
- Create new books
- Retrieve all books
- Retrieve book by ID
- Update book details
- Delete a book
- Register new users
- Login with username & password
- JWT authentication
- Secure password hashing (BCrypt)
- ASP.NET Core Web API
- Entity Framework Core
- SQLite Integration
- Layered folder structure
- DTO models for input validation
Library Management System/
├── Controllers/
│ ├── AuthController.cs # User Register/Login
│ ├── BookController.cs # CRUD endpoints for books
│ └── WeatherForecastController.cs # Default sample
│
├── Data/
│ └── AppDbContext.cs # EF Core DB Context
│
├── Migrations/ # Auto-generated EF Migrations
│
├── Models/
│ ├── AddBookDto.cs # DTO for adding books
│ ├── UpdateBookDto.cs # DTO for updating books
│ ├── UserDto.cs # DTO for user authentication
│ ├── Book.cs # Book model
│ └── User.cs # User model
│
├── library.db # SQLite database
├── appsettings.json # DB + JWT Config
├── Program.cs # API configuration
└── README.md
| Layer | Technology |
|---|---|
| Backend Framework | ASP.NET Core Web API |
| Database | SQLite |
| ORM | Entity Framework Core |
| Authentication | JWT (JSON Web Tokens) |
| Password Hashing | BCrypt.Net |
| Language | C# |
| Tooling | .NET 8 |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/books |
Get all books |
| GET | /api/books/{id} |
Get book by ID |
| POST | /api/books |
Add a new book |
| PUT | /api/books/{id} |
Update a book |
| DELETE | /api/books/{id} |
Delete a book |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register a new user |
| POST | /api/auth/login |
Login user + return JWT token |
SQLite database file is auto-generated:
library.db
library.db-shm
library.db-wal
EF Core handles migrations.
Make sure you have:
- .NET 8 SDK
- SQLite installed (optional)
In appsettings.json:
"ConnectionStrings": {
"DefaultConnection": "Data Source=library.db"
}dotnet ef database updatedotnet runBackend will run on:
https://localhost:7036
http://localhost:5239
(Ports may vary based on your system)
User provides:
- username
- password
Password is hashed using BCrypt.
- Validate password
- Generate JWT token
- Frontend stores token in localStorage
You can protect routes using:
[Authorize]Inside appsettings.json:
"Jwt": {
"Key": "YOUR_SECRET_KEY_HERE",
"Issuer": "library-api",
"Audience": "library-api"
}Use a long, secure key for real apps.
You can use:
- Postman
- Thunder Client (VS Code)
- Swagger UI (built-in)
Swagger loads automatically at:
https://localhost:7036/swagger
- Code follows clean architecture principles
- DTOs used for safety and input validation
- Controllers separated for maintainability
- Easy to integrate with any frontend (React, Vue, Angular)
MIT License – Free to use, modify, and distribute.
- Microsoft ASP.NET Core Team
- Entity Framework Core
- BCrypt.Net
- SQLite Development Team