The RestaurantAPI project is a RESTful API built with .NET 6, designed to provide backend solutions for restaurant management.
It includes features such as user authentication, static file handling, and CRUD (Create, Read, Update, Delete) operations, tailored for managing restaurant data.
Secure access is ensured using JWT (JSON Web Tokens), allowing users to authenticate and receive a token for subsequent requests.
Users are granted access to specific resources and operations based on their assigned roles (e.g., Admin, Manager, Employee).
Supports the full range of operations for managing restaurant data, such as menus, orders, and reservations.
The API can manage static files like images, PDFs, etc.
The API supports pagination for data-heavy endpoints, providing:
- Total Pages: The number of pages available (configurable).
- Results Per Page: The number of items displayed per page (configurable).
- Total Items: The total count of elements in the database.
- Sorting: Data can be sorted by various attributes like name, date, etc.
- Filtering: Results can be narrowed down by applying specific filters (e.g., by cuisine type, rating, location).
The application includes an automatic seeder that populates the database with sample data when the application starts, providing a ready-to-use environment for testing.
Used extensively to manage dependencies, promoting modularity, maintainability, and testability.
Data Transfer Objects (DTOs) are used for efficient data representation between layers.
Ensures validation rules are applied consistently and declaratively across requests.
The following technologies are used in the project:
- ASP.NET Core 6: For building the API.
- Entity Framework: ORM for interacting with the database.
- LINQ: For querying data.
- DTO Mapping: Simplifies data transfer between API layers.
- Fluent Validation: For input validation.
- JWT Authentication: Secures endpoints with JSON Web Tokens.
- NLog: For logging API requests and errors.
- Swagger: For interactive API documentation and testing.
- Bogus: Used to generate fake data for testing purposes.
The project includes integration tests implemented using xUnit and Moq to ensure the reliability of API endpoints and interactions.
- xUnit: A robust and flexible testing framework for .NET applications.
- Moq: A popular mocking library for .NET that allows creating and configuring mock objects to isolate tests.
- Authentication and Authorization: Verifying that only authenticated users with proper roles can access secured endpoints.
- CRUD Operations: Ensuring data creation, retrieval, updates, and deletion functions work as expected.
- Validation: Testing that invalid inputs are properly handled and validated.
- Database Interactions: Mocking database interactions to test business logic without relying on the actual database.
To get started with the project, follow these steps:
git clone https://github.com/albertgmi/RestaurantAPI.git
cd RestaurantAPIdotnet restoreThe application includes an automatic seeder that will populate the database with sample data when the application starts.
Ensure the database connection is correctly configured in the appsettings.Developement.json file.
If the dotnet-ef tool is not installed, use the following command to install it globally:
dotnet tool install --global dotnet-efdotnet ef database updatedotnet runFor instance: http://localhost:5176/swagger/index.html