GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” GitHub - harshu10-coder/AddressBookApi: AddressBook API is a full-featured ASP.NET Core Web API project that follows RESTful principles, implements JWT-based authentication, and uses Entity Framework Core for database operations.

BranchesTags
Open more actions menu

Latest commit

 

History

3 Commits
3 Commits

Folders and files

NameName
Last commit message
Last commit date
Controllers
Controllers
 
 
DTOs
DTOs
 
 
Data
Data
 
 
Migrations
Migrations
 
 
Models
Models
 
 
Properties
Properties
 
 
Services
Services
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
AddressBookApi.csproj
AddressBookApi.csproj
 
 
AddressBookApi.http
AddressBookApi.http
 
 
AddressBookApi.sln
AddressBookApi.sln
 
 
Program.cs
Program.cs
 
 
README.md
README.md
 
 
appsettings.Development.json
appsettings.Development.json
 
 
appsettings.json
appsettings.json
 
 

Repository files navigation

πŸ“˜ Address Book API

Address Book API is a backend project that allows users to manage their personal contacts efficiently. It is built using ASP.NET Core Web API, Entity Framework Core, and JWT Authentication with Role-Based Authorization.

This API supports CRUD (Create, Read, Update, Delete) operations for contacts, while JWT ensures authentication and roles (Admin/User) handle authorization.

πŸš€ Features

  • πŸ” JWT Authentication & Role-Based Authorization
  • 🧾 CRUD Operations on Contacts
  • 🧠 Entity Framework Core for database management
  • πŸ“‚ Layered Architecture (Controller, Service, Model, Data)
  • 🧰 Swagger Integration for API testing
  • πŸ’Ύ SQL Server Database Connection

🧩 Tech Stack

Category Technology
Framework ASP.NET Core Web API
Language C#
Database SQL Server
ORM Entity Framework Core
Authentication JWT (JSON Web Token)
Architecture RESTful API
Testing Tool Swagger UI
IDE Visual Studio 2022

πŸ—‚οΈ Project Structure

AddressBookApi/
β”‚
β”œβ”€β”€ Controllers/
β”‚   └── ContactsController.cs, AuthController.cs
β”‚
β”œβ”€β”€ Data/
β”‚   └── ApplicationDbContext.cs
β”‚
β”œβ”€β”€ Models/
β”‚   β”œβ”€β”€ Contact.cs
β”‚   └── User.cs,Role
β”‚
β”œβ”€β”€ Services/
β”‚   β”œβ”€β”€ IContactService.cs
β”‚   └── ContactService.cs, BetterContactServices.cs
β”‚
β”œβ”€β”€ Helpers/
β”‚   └── JwtHelper.cs
β”‚
β”œβ”€β”€ Program.cs
└── appsettings.json

βš™οΈ Setup Instructions

1️⃣ Clone the Repository

git clone https://github.com/harshu10-coder/AddressBookApi.git
cd AddressBookApi

2️⃣ Configure Database

appsettings.json Update your Connection String here:

"ConnectionStrings": {
  "DefaultConnection": "Server=YOUR_SERVER;Database=AddressBookDb;Trusted_Connection=True;TrustServerCertificate=True;"
}

3️⃣ Apply Migrations

dotnet ef database update

4️⃣ Run the Application

dotnet run

Open Swagger UI:
πŸ‘‰ https://localhost:5001/swagger


πŸ”‘ Authentication (JWT)

  • When a user logs in a JWT Token is generated.
  • The token must be pasted into the Authorize button in Swagger.
  • Only users with a valid token can access the protected endpoints.

Example Token Format:

Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

πŸ“ API Endpoints

πŸ”Έ Auth Endpoints

Method Endpoint Description
POST /api/Auth/register Register new user
POST /api/Auth/login Login and get JWT token

πŸ”Έ Contact Endpoints

Method Endpoint Description Access
GET /api/Contacts/allcontacts/all Get all contacts Admin, User
GET /api/Contacts/Contactedbyid/{id} Get contact by ID Admin, User
POST /api/Contacts/CreateContact/add Add a new contact Admin
PUT /api/Contacts/UpdateContact/{id} Update a contact Admin
DELETE /api/Contacts/deleteContact/{id} Delete a contact Admin

πŸ” Role-Based Authorization

Role Permissions
Admin Can Create, Update, Delete, and View all contacts
User Can only View contacts

🧠 Learning Goals

  • ASP.NET Core Web API development
  • Using Entity Framework Core for database interaction
  • Understanding JWT-based authentication
  • Implementing role-based authorization
  • Building RESTful API endpoints
  • Testing API with Swagger

🧰 Requirements

  • .NET 8 SDK or higher
  • SQL Server (local or remote)
  • Visual Studio 2022 or VS Code
  • Postman / Swagger for testing

πŸ§‘β€πŸ’» Author

Harsh Kumar
πŸŽ“ BCA Student | πŸ’» Aspiring Full Stack Dot Net Developer
πŸ”Ή Skills: ASP.NET Core |Asp.NET WebApi| SQL Server | Oracle | HTML | CSS | Bootstrap | C# |
🌐 GitHub: harshu10-coder


πŸ’« Future Enhancements

  • βœ… Add refresh token mechanism
  • βœ… Integrate frontend using ASP.NET MVC or React
  • βœ… Deploy API to Azure or Render

⭐ Support

If you found this project useful, don’t forget to Star ⭐ it! It helps motivate me and encourages more new projects πŸš€

🏷️ Tags

aspnet-core β€’ webapi β€’ restapi β€’ jwt-authentication β€’ entity-framework-core β€’ sql-server β€’ dotnet

About

AddressBook API is a full-featured ASP.NET Core Web API project that follows RESTful principles, implements JWT-based authentication, and uses Entity Framework Core for database operations.

Topics

aspnet-core-webapicrud-operationscsharpdotnet-coreentity-framework-corejwt-authenticationrestapi-backendsql-serverswagger-ui

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.