Running project locally - ita-social-projects/WhatBackend GitHub Wiki

Running project locally

Required steps:

  1. Install software
  2. Clone repository
  3. Run scripts to create and seed database
  4. Add .env files
  5. Start project
  6. Running admin panel

Install software

In order to run a project on your local machine, these software is required to be installed:

Clone repository

Clone this repository using your IDE or git clone command. You need to clone branch dev.

Run scripts to create and seed database

This Web API project uses MySQL database as a data storage. In order to create and seed database with initial data you are required to run SQL scripts in the following order: 1_[name_of_script], 2_[name_of_script], ..., n_[name_of_script].

All scripts are located in the corresponding folder: <RepositoryRootFolder>\scripts\

NOTE: Before running the scripts, make sure there is no database named Soft in your local instance of MySQL.

NOTE: To deal with MySQL use MySQL Workbench 8.0 CE or later versions of this application.

Add .env files

This Web API application uses DotNetEnv library and reads environment variables from .env files.

In order to run the application you need to create and place .env files with the following contents into corresponding folders.

  1. Location: <RepositoryRootFolder>\CharlieBackend.Api\ Contents:
# dev local mySql connection string

ConnectionStrings__DefaultConnection=server=localhost;port=3306;UserId=<YOUR_ID>;Password=<YOUR_PASSWORD>;database=soft;
ConnectionStrings__RabbitMQ=<RABBIT_MQ_CONNECTION_STRING>
ConnectionStrings__AzureBlobsAccessKey=<AZURE_BLOBS_ACCESS_KEY_CONNECTION_STRING>

# dev local token

AuthOptions__KEY=<JWT_SECRET_KEY>

# email notifier account credentials

CredentialsSendersSettings__email=<CRED_SENDER_EMAIL>

CredentialsSendersSettings__password=<CRED_SENDER_PASSWORD>

Replace <YOUR_ID> and <YOUR_PASSWORD> with your own MySQL credentials. Also, check if your local MySQL instance runs on port specified in the connection string.

Replace <JWT_SECRET_KEY> with a valid secret key value that is used to sign JWT on creation.

Replace <CRED_SENDER_EMAIL> and <CRED_SENDER_PASSWORD> with valid credentials of email notification sender account.

Replace <RABBIT_MQ_CONNECTION_STRING> and <AZURE_BLOBS_ACCESS_KEY_CONNECTION_STRING> with valid connection strings.

NOTE: .env files contain no filename, only extension.

NOTE: You can find out the correct data to fill out from your teammates, mentor or technical expert.

  1. Location: <RepositoryRootFolder>\CharlieBackend.AdminPanel\ Contents:
# devlocalhost cookies key

 Cookies__SecureKey=<SECURE_KEY>

Replace <SECURE_KEY> with a valid secure key value that is used for encryption/decryption of cookie data.

NOTE: .env files contain no filename, only extension.

NOTE: You can find out the correct data to fill out from your teammates, mentor or technical expert.

Start project

Make sure your local MySQL instnance is up and running.

In this step open CharlieBackend.sln with your IDE and run the project.

Or if you're willing to use CLI, type dotnet run console command inside <RepositoryRootFolder>\CharlieBackend.Api\ folder and navigate to http://localhost:5000 or https://localhost:5001.

In case of a successful application run you should receive Swagger (OpenAPI) page that represents UI for available Web API endpoints.

Running admin panel

"Admin panel" is an additional web application project that is located inside <RepositoryRootFolder>\CharlieBackend.AdminPanel\ folder.

In order to run admin panel, it requires the main application (CharlieBackend.Api) that is already running.

Run CLI script run-localhost-what-api.cmd that starts the main application. Then run admin panel project with your IDE, or run run-localhost-what-adminpanel.cmd script and navigate to http://localhost:5002 or https://localhost:5003/.

Both CLI scripts are located inside <RepositoryRootFolder>\cli_scripts\ folder.

In case of a successful application run you should receive Login page of admin panel.

Deploying in Azurite

Azurite is an emulator for local Azure Storage development. You can find instructions how to deploy your application in Azurite at Azurite setup guide.

⚠️ **GitHub.com Fallback** ⚠️