BookStoreAPI is a RESTful API built using .NET Core. It provides functionality to manage a bookstore's inventory, customers, and orders. The application is designed with a code-first approach using Entity Framework and integrates JWT-based authentication for secure access.
- Book Management: Add, update, delete, and retrieve books.
- Customer Management: Register customers and manage their details.
- Order Processing: Create and manage book orders.
- Authentication: Secure endpoints using JSON Web Tokens (JWT).
- Admin Management: Create and manage admin accounts.
- Author and Catalog Management: Manage authors and organize books into catalogs.
Before running this application, ensure you have the following installed:
- .NET SDK (version 6.0 or later)
- SQL Server
- Postman or any API testing tool (optional)
-
Clone the repository:
git clone https://github.com/mahmoud-40/BookStoreAPI.git cd BookStoreAPI
-
Restore dependencies:
dotnet restore
-
Set up the database:
- Update the connection string in
appsettings.json
to match your SQL Server configuration. - Apply migrations to create the database:
dotnet ef database update
- Update the connection string in
-
Run the application:
dotnet run
-
The API will be available at
https://localhost:5001
(orhttp://localhost:5000
for non-HTTPS).
- POST
/api/Account
: Login - PUT
/api/Account/ChangePassword
: Change Password - POST
/api/Account/logout
: Logout
- POST
/api/Admin
: Create a new admin - GET
/api/Admin
: Get all admins
- GET
/api/Author
: Get all authors - POST
/api/Author
: Add an author - GET
/api/Author/{id}
: Get an author by id - PUT
/api/Author/{id}
: Update an author - DELETE
/api/Author/{id}
: Delete an author
- GET
/api/Book
: Get all books - POST
/api/Book
: Create a book - GET
/api/Book/{id}
: Get a book by id - PUT
/api/Book/{id}
: Update a book - DELETE
/api/Book/{id}
: Delete a book
- GET
/api/Catalog
: Get all catalogs - GET
/api/Catalog/{id}
: Get a catalog by id - POST
/api/Catalog/{catalogId}/books/{bookId}
: Add a book to a catalog
- POST
/api/Customer
: Create a new customer - GET
/api/Customer
: Get all customers - GET
/api/Customer/{id}
: Get a customer by id - PUT
/api/Customer/{id}
: Edit a customer - PUT
/api/Customer/ChangePassword
: Change password
- POST
/api/Order
: Add a new order - GET
/api/Order
: Get all orders - GET
/api/Order/{id}
: Get an order by id - DELETE
/api/Order/{id}
: Delete an order - PUT
/api/Order/{id}
: Update an order status
Below is the database schema used in the BookStoreAPI project:
- AspNetUsers: Stores user information (customers, admins) with authentication details.
- Books: Represents books available in the bookstore.
- Authors: Contains author details.
- Orders: Tracks customer orders.
- OrderDetails: Includes details of books in each order.
- Catalogs: Organizes books into specific categories.
- AspNetUsers and Orders: A one-to-many relationship where a user can place multiple orders.
- Orders and OrderDetails: Each order can have multiple books associated with it.
- Books and Authors: A many-to-one relationship where books are written by authors.
- Books and Catalogs: A many-to-one relationship to organize books into catalogs.
- .NET Core: Backend framework.
- Entity Framework Core: Database management.
- SQL Server: Database.
- JWT: Authentication and authorization.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -m "Describe your feature"
- Push to the branch:
git push origin feature-name
- Create a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or feedback, please contact:
- Email: mahmouda.mawlaa@gmail.com
- GitHub: mahmoud-40