Skip to content

TrawenCZ/bookhub

Repository files navigation

BookHub

💡 This project was created as an assignment for the "System Development in C#/.NET" course at FI MUNI.

A digital platform for the company called "BookHub", a company that sells books of various genres. The platform facilitates easy browsing and purchase of books, letting customers sort and filter by authors, publishers, and genres. Customers can create accounts, review their purchase history, rate books, and make wishlists. Administrators have privileges to update book details, manage user accounts, and regulate book prices.

Quick Start 🛠️

⚠️ Please note that this application requires .NET and its Entity Framework Tools package, both version 8.0 or newer. You can check .NET version by running dotnet --version command and Entity Framework Tools package version with dotnet ef --version command. It also requires Docker to be installed and running on your machine. If you don't have Docker installed, you can download it from Docker's official website.

To install .NET, visit Microsoft's official website and follow the instructions. To install Entity Framework Tools package, run dotnet tool install --global dotnet-ef.

This section will walk you through starting the application in Development mode. If you have Package Manager Console (PMC), there may be listed shorter PMC alternatives of the same command:

  1. 📜 Check if your computer has and trusts development SSL certificate. This command will check if certificate is present and trusted - and if not, it tries to create and trust a new one:

    (dotnet dev-certs https --check --trust) -OR (dotnet dev-certs https --trust) 2>$1 > $null
  2. 🌱 Initialize database. Run this to apply the migrations and initialize database along with the data (this action may take a while):

    dotnet ef database --project=WebAPI update
    PMC Alternative
    Update-Database

  3. ⚙️ Add application launch configuration to WebAPI/Properties/launchSettings.json file.

    You can either do it manually by copying code from File Content section (and create both the Properties directory and launchSettings.json file yourself), or running the command from the Command section. Of course, feel free to modify the content to suit your needs.

    File Content
    {
      "profiles": {
        "WebAPI": {
          "commandName": "Project",
          "launchBrowser": true,
          "launchUrl": "swagger",
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
          },
          "applicationUrl": "https://localhost:64053;http://localhost:64054"
        }
      }
    }
    Command
     md WebApi/Properties 2>$1 > $null ; echo '{
      "profiles": {
        "WebAPI": {
          "commandName": "Project",
          "launchBrowser": true,
          "launchUrl": "swagger",
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
          },
          "applicationUrl": "https://localhost:64053;http://localhost:64054"
        }
      }
    }' > WebApi/Properties/launchSettings.json

    You should also provide development app setings file for the WebAPI and WebMVC projects. You can start with it by creating it out of example files with:

    Copy-Item WebAPI/appsettings.Development.json.example WebAPI/appsettings.Development.json

    and

    Copy-Item WebMVC/appsettings.Development.json.example WebMVC/appsettings.Development.json

    Then, you can modify the WebAPI/appsettings.Development.json and WebMVC/appsettings.Development.json files to suit your needs.


  4. 🐋 Startup required database and log storage as a pre-configured Docker container. First of all, initialize the .env file with the following command. You should modify the content as it contains database credentials, but it will work fine with the default values:

    🗒️ These credentials need to be the same as in the WebAPI/appsettings.Development.json file!

    Copy-Item .env.example .env

    The databases should automatically start up before the application if you're developing in VisualStudio.

    If not, start the containers containing databases with this command:
    docker compose -f docker-compose-dev.yml up -d

  5. 🚀 Start the application through your IDE (select WebMVC as startup project).

    If you are not using IDE, you can also start it with .NET watch command.

    .NET WebMVC watch command
    dotnet watch --project=WebMVC

    🗒️ If you aim to only use backend part of this application, select WebAPI as startup project. Again, if not in IDE, you can use this command:

    .NET WebAPI watch command
    dotnet watch --project=WebAPI

Project Structure 🧱

The solution consists of these projects:

DataAccessLayer🔗

  • This project serves as a layer just above the database, providing communication with database through Entity Framework.
  • Entities directory contains classes that represent database tables.
  • DataGenerator class is used to seed the database with initial data (leverages the Bogus library).
  • BookHubDbContext class is the main entry point for database communication.

WebAPI🔗

  • This project is the main entry point of the application, providing RESTful API endpoints for the frontend.
  • Middlewares directory contains custom middlewares for request data validation and manipulation.
  • Controllers store endpoint definitions and their logic for each entity.

BusinessLayer🔗

  • This project contains the business logic of the application, serving as a bridge between the API and the database.
  • Services directory contains classes that implement business logic for each entity.
  • DTOs directory contains classes that represent data transfer objects for each entity.
  • Mappers directory contains classes that map entities to DTOs and vice versa.
  • Utils directory contains utility classes for various purposes.

Infrastructure🔗

  • This project contains classes that provide infrastructure services for the application.
  • Repository directory contains classes that implement the repository pattern for each entity.
  • UnitOfWork class is used to manage transactions across multiple repositories.

WebMVC🔗

  • This project is the frontend of the application, providing a user interface for customers and administrators.
  • Controllers directory contains controller classes that handle user requests.
  • Views directory contains Razor views that render HTML content for the user interface.
  • Models directory contains classes that represent data for the views.
  • wwwroot directory contains static files like CSS, JavaScript, and images.

BusinessLayer.Tests🔗

  • This project contains unit tests for the business logic of the application.
  • Services directory contains test classes for service classes.

BookHub.Shared🔗

  • This project contains shared classes that are used across multiple projects.

BookHub.sln🔗

  • This file is the solution file that contains references to all projects in the solution.

Data Model 🗃️

An Entity Relationships Diagram that illustrates the underlying data model in the application.

ERD

Action Model 🖱️

A Use Case Diagram that illustrates available actions for different actors using the application.

UCD

About

This is a semestral group project from a Advanced C# programming course at FI MUNI. It has been developed with a help of two other students: Dominik Masár and Adam Balušeskul.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages