Skip to content

AmanyZayed/CourseManagementAPI

Repository files navigation

Course Management System API

Overview

This project is an ASP.NET Core Web API for managing students, courses, and instructors. It demonstrates database relationships, authentication using JWT, and clean architecture using DTOs and services.


Technologies Used

  • ASP.NET Core Web API
  • Entity Framework Core
  • SQL Server
  • JWT Authentication
  • LINQ

Features

  • CRUD operations for Students

  • DTOs for request and response handling

  • Service layer for business logic

  • Entity relationships:

    • One-to-One (Instructor ↔ Profile)
    • One-to-Many (Instructor → Courses)
    • Many-to-Many (Student ↔ Course via Enrollment)
  • JWT Authentication & Authorization

  • Protected endpoints using [Authorize]

  • Optimized queries using LINQ and AsNoTracking()


Database Structure

The database includes the following tables:

  • Students
  • Courses
  • Instructors
  • InstructorProfiles
  • Enrollments (Junction table)
  • Users

The Enrollment table is used to implement a Many-to-Many relationship between Students and Courses.


Authentication

The API uses JWT (JSON Web Token) for authentication.

Login Endpoint:

POST /api/auth/login

Request Body:

{
  "username": "admin",
  "password": "1234"
}

Response:

{
  "token": "token"
}

To access protected endpoints, include the token in the header:

Authorization: Bearer TOKEN

API Endpoints

Students:

  • GET /api/students → Get all students
  • POST /api/students → Create new student
  • PUT /api/students/{id} → Update student
  • DELETE /api/students/{id} → Delete student

How to Run the Project

  1. Open the project in VS Code

  2. Run the following command:

    dotnet run
    
  3. The API will run on:

    http://localhost:5109
    
  4. Use Postman to test endpoints


Testing

The API was tested using Postman:

  • Login to get JWT token
  • Access protected endpoints using Authorization header
  • Verified unauthorized access returns 401

Why HTTP-only Cookies?

HTTP-only cookies are used in real-world applications because:

  • They prevent JavaScript access (protect against XSS attacks)
  • They improve security of authentication tokens
  • They reduce the risk of token theft

Author

Amany sameeh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages