---
# System prepended metadata

title: Onboarding notes

---

---
title: 'Onboarding notes'
disqus: hackmd
---


# Onboarding notes
Welcome to Treecastle. We’re so glad to have you join the team! This guide is meant to provide team specific information to help you get off to a great and productive start. 
 
## Setting up development environment

Here is one way in which you can set up our environment for development. Of course, you are free to use whatever tool/ IDE you feel comfortable with (VSCode, Jetbrains Rider etc).

### Basic requirements for setup: 

* Must be running Windows OS. If you do not have a Windows machine, you can run a Windows VM (Virtualbox is a good option). Alternatively, you can dual boot Windows (It's pretty straightforward on Mac with BootCamp).

* Must have visual studio:  [download](https://visualstudio.microsoft.com/downloads/) choose the community version 

* Must have SqlServer: [download](https://www.microsoft.com/en-us/sql-server/sql-server-downloads) choose the developer version 

* Must have SqlServer management studio: [download](https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15) 

* Must have access to the Github repo (Steve should have given you)

* Must have .NET 4.7.1 [here](https://dotnet.microsoft.com/download/dotnet-framework/net471) both runtime and developer pack 

* Please download the file localDatabaseCreation.sql from the documentation folder. It is an SQL script that generates a database and populate it with the same data as on Hugo's machine.

https://1drv.ms/u/s!ApdFg50lIdxqhpgttpI16CKV4yHe9g?e=0pDwMd 

 
### Steps for setting up: 
1) Clone the repository
-  Go to Github and get the repository clone link
- VisualStudio >> File >> Clone Repository paste the link

2) Set up the database

- Open the file localDatabaseCreation.sql in SQL management studio
- Verify the file name at the top (Most likely it is fine)
- Execute the script
- Open the database DB_A4B4AC_CntTransformDEV and ensure that it is not empty

3) Check that the database is working properly

- VisualStudio>>Tools>>Nuget Package Manager >> Package Manager Console.
- Run update-database command. It should say no pending migrations.

4) Change Config file:

- Open the file Common/CommonSettings.config and change "u_der" (Umut's username) to the username of your computer. This is for storing files during development.
- Change the value of value of agencyId to 1.

5) Build and run the projects ContentTransformer.WebUI and ContentTransformer.WebAPI. They need to be running (at http://localhost:51388/ and http://localhost:51325/ respectively) even when doing React development
 
6) For React, go to the /React folder in the ContentTransformer.React project. Run npm install, then npm start. Then build and run the React project.

## Backend and MVC App


### Architecture 
![](https://i.imgur.com/ABeCSMu.png)



**SmptClient** 
We don't use other 3rd party email services(ex. SendGrid), we instead use "SmtpClient", you can have a look into its implementation in a class called "Helper".


**MemoryCache** 
We don't use other cache services (ex. Redis server instead, we use our implementation for MemoryCache (check the class named "CacheManager.cs")

**Host Server Hard Drives**
Where we store files uploaded by clients?
We don't have any 3rd party DBs for storing docs, instead we store them locally on our host server on their hard drives.

**EF Provider**
MS SQL Server

**Ninject Package**
We use Ninject package managing and applying the "Dependency Injection" pattern. This package is implemented internally in the .NET Core.

**Identity**
Microsoft Identity Model

### Deployment
The application is deployed as a single web application running within a single IIS domain. Most of the time, a more experienced member of the team will do the deployment, so you probably need not worry about this.

![](https://i.imgur.com/AQ2daOF.png)

### Design Principles
* ContentTransform product is a MVC Web Application using n-tier architecture.

![](https://i.imgur.com/WEFrzHj.png)

* Entity Framework(Code First)
* Repository Pattern
* Dependency Injection


### Solution details
**Services**
1. AgencyManagerService
2. AgencyService - Agency CRUD
3. BuyerService - Buyer CRUD
4. CartService -Cart CRUD
5. CompanyService - Company CRU
6. DocumentService - Document CRUD
7. EmailTemplateService
8. FileInfoService - CalculatePageCount, CalculateUnitCount, CalculateWordCount, and ExtractText
9. JobService - supplier job CRUD
10. LanguageService - GetAllLanguages, and GetAgencyLanguages
11. PasswordResetService
12. PaymentService
13. PriceService - GetPriceList, GetSubTotalPrice, CRUD PriceSheetDetail, and CRUD PriceSheet
14. ProjectManagerService - Read and create project manager
15. RequestService - address any requests from Buyer, Supplier, and Project Manager.
16. SupplierFacilityService
17. SupplierService
18. TranslationService
19. UserService
20. WorkflowService

**Modules**
1. NinjectModule
2. TelemetryModules

**Components**
1. Common Language Runtime or CLR
2. .Net Framework Class Library


### Source code

* All source code about database operation are under Core project. 

* Using Message Digest 5 (MD5) hashing algorithms for Password.

* Use Razor to Generate HTML for Templates in a Single-Page App
https://docs.microsoft.com/en-us/archive/msdn-magazine/2018/march/asp-net-use-razor-to-generate-html-for-templates-in-a-single-page-app

#### Type of data binding 
https://www.tutorialspoint.com/asp.net/asp.net_data_binding.htm

#### Security measures
[Create an ASP.NET MVC 5 App with Facebook, Twitter, LinkedIn and Google OAuth2 Sign-on](https://docs.microsoft.com/en-us/aspnet/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on)
[XSRF/CSRF Prevention in ASP.NET MVC and Web Pages](https://docs.microsoft.com/en-us/aspnet/mvc/overview/security/xsrfcsrf-prevention-in-aspnet-mvc-and-web-pages)
[Preventing Open Redirection Attacks](https://docs.microsoft.com/en-us/aspnet/mvc/overview/security/preventing-open-redirection-attacks)
[ASP.NET MVC 5 app with SMS and email Two-Factor Authentication](https://docs.microsoft.com/en-us/aspnet/mvc/overview/security/aspnet-mvc-5-app-with-sms-and-email-two-factor-authentication)


### Maintenance or help guide

Describe known problems with the system and their solutions. It also should represent the dependencies between different parts of the system.

#### Dependency

![](https://i.imgur.com/Kfk9LTq.png)
The screenshot above is the project structure from Visual Studio. The solution **"ContentTransformer"** contains  four projects which are **WebUI, WebApi, Core, and Common**. The project of WebUI, WebApi, and Core depend on the project Common.The project of WebUI, and WebApi depend on the project Core. *Figure 2* is the dependency diagram that represents the dependencies between different projects.

![](https://i.imgur.com/FHx2I73.png)

### Common Issues
1. Migration conflicts
- Description: Pulling new changes from github might cause the issue. When you login local server, "Unexpected Error" errors message shows on login page.
- Resolution:
1.Uncomment local connectionStrings in App.config under Common project
2.Run "update-database" in package manager console
2. How to get Enum description attribute in view?
```java=
@using ContentTransformer.Core.Extensions;

@Model.SupplierStatus.GetDescription()
```
3. Changes to .js files are not reflected on the site being developed

- Clear your browser history and data. Probably it's because the browser cached the old file.


#### Learning Resources
All technologies used in this product are classified in [ASP.NET Core Developer Roadmap](https://github.com/MoienTajik/AspNetCore-Developer-Roadmap) 

This site provides quite detailed instructions on various parts of ASP.NET Core. It's in Russian originally but you can use Google Translate: [Metanit](https://translate.google.com/translate?hl=en&sl=ru&u=https://metanit.com/sharp/mvc5/5.12.php&prev=search&pto=aue)

## React frontend

## Testing

### API Testing with postman(In setting step)
### Functional Testing with Units Tests(In setting step)
### UI Testing with Seleium

## API documentation

The documentation informs developers **how to effectively use and connect to the required APIs**.


* Stripe API 
The Stripe API is organized around **REST**. The Stripe API has predictable resource-oriented URLs, accepts **form-encoded** request bodies, returns **JSON-encoded** responses, and uses standard HTTP response codes, authentication. Stripe authenticates your API requests using your account’s API keys. If you do not include your key when making an API request, or use one that is incorrect or outdated, Stripe returns an error. We handle API Key in the function "CreateStripeSession" under the file "RequestController.cs" which path is "ContentTransformer\ContentTransformer.WebApi\Controllers\RequestController.cs".

* Google API
In order to use a specific service, you have to add a reference to it. For example we use the Translate API, we installed its NuGet package Google.Apis.Translate.v2.The *Figure* shows what Google API we use. All API calls must use either simple or authorized access. We use simple access which API calls do not access any private user data. The application must authenticate itself as an application belonging to your Google API Console project. We handle API Key under the file "TranslationService.cs" which path is "ContentTransformer\ContentTransformer.Core\Services\TranslationService.cs"
![](https://i.imgur.com/cRagCX4.png)


## Video walkthrough of features and codebase

We have made some video walkthroughs of the MVC codebase and functionalities, but there has been several changes since they were recorded. One of the best ways to get a better understanding of it is getting your hand dirty and dive into the codebase.

[Features](https://1drv.ms/v/s!ApdFg50lIdxqhcx148Vd8Mglmd8_IQ?e=kGRirc)

[Codebase](https://1drv.ms/v/s!ApdFg50lIdxqhcx0M2n5zeGtnyAjsA?e=eakhsD)

## Glossary



