/LibraCore-Backend

LibraCore-Backend is a hands-on project aimed at learning .NET API development. 📝

Primary LanguageC#

LibraCore Backend 📚

This is a hands-on project for learning .NET API development, aimed at creating the backend for a Library Management System. 🚀


🛠️ Setup and Running the Application

1. Set Environment Variables

Before running the application, make sure to set the environment variables for sensitive credentials.

Steps:

  1. Ensure you're in a BASH terminal.

  2. Run the shell script to set the environment variables:

    source Deployment/set_env_vars.sh

2. Import Database Dump

Before running the application, you need to import the provided database dump.

Steps:

  1. Ensure you have MySQL installed and running on your machine.
  2. Navigate to the Database folder where the dump file is located.
  3. Run the following command to import the database dump:
    mysql -u [username] -p [database_name] < Database/dump.sql
    Replace [username] with your MySQL username and [database_name] with the name of the database you want to create or use.

3. Run the Application

Once the environment variables are set and the database is imported, you can run the application.

  • To run the application with HTTPS:
    dotnet run --launch-profile https
  • To run the application with hot reload:
    dotnet watch

4. Access Swagger Documentation

After running the application, you can access the Swagger documentation to explore and test the API endpoints.

⚙️ Useful Commands

💻 .NET

Run with a Launch Profile

To run the application with the specified launch profile (e.g., HTTPS):

dotnet run --launch-profile https

Run with Hot Reload

To start the application with hot reload (automatically reload changes without restarting the app):

dotnet watch

List Installed .NET SDKs

To see all the installed .NET SDK versions on your machine:

dotnet --list-sdks

View Installed Packages in the Project

To list all the packages currently being used in the project:

dotnet list package

🧑‍💻 Git Commands

Generate the Default .gitignore File

To create a .gitignore file with default settings suitable for .NET projects:

dotnet new gitignore

✅ Key Concepts Covered

  • ☑︎ Versioning
    • Supports URL segment versioning (e.g., api/v1.0/User)
  • ☑︎ ORM for MySQL
    • Using the EntityFrameworkCore to interact with the MySQL database.
  • ☑︎ Basic CRUD operations
  • ☑︎ Centralized exception handling
    • Using the Middleware to streamline error handling across the application.
  • ☑︎ Sensitive credentials management
    • Storing credentials securely with the Environment Variables.
  • ☑︎ Authentication and Authorization
    • Authentication is implemented using Auth0 as the OAuth2 client. Scope-based authorization is enforced via endpoint-specific decorators. For more details, refer to the documentation: Auth0 Quickstart for ASP.NET Core Web API.
  • ☑︎ Input Validation
    • Validating request bodies with the FluentValidation library.
  • ☑︎ API Response Customization and Optimization
    • Using query parameters to customize and optimize API responses, such as controlling the inclusion of related data.
  • ☐ Pagination and Filtering
  • ☐ Logging and Monitoring
  • ☐ Unit Testing
  • ☑︎ API Documentation
    • Uses Swashbuckle to generate Swagger UI for exploring and testing API endpoints with versioning and JWT authentication.
  • ☐ Database Migration
  • ☐ Resilience and Fault Tolerance
    • Implemented using Polly for strategies like retries, circuit breakers, and fallback policies.

Happy coding! 😊