Setup - medhatelmasry/GoodBooks GitHub Wiki
https://github.com/AccountGo/accountgo
.NET 8.0
Backend: ASP.NET WebAPI
Frontend: MVC(Only For UI) or React with TypeScript
Database: SQL Server
Note: Blazor has been injected into the MVC app in case there is a desire to migrate certain pages to SPA.
It seems the development on this app stopped about seven years ago. When I looked at it, I figured that it has most of what is needed and could be useful by upgrading the application to the latest state of .NET and React. Therefore, I forked it and updated it to the latest versions of .NET, React, and TypeScript.
- Clone the repo:
git clone https://github.com/medhatelmasry/GoodBooks.git cd GoodBooks/
- List branches with:
git branch -r
- Select the appropriate branch with:
git checkout -b my-branch
Replace my-branch with the branch you want to change to. Choose the development branch named endpoint_sahil. The following command creates a new branch called endpoint_sahil (-b) that tracks the remote branch origin/endpoint_sahil:
git checkout -b endpoint_sahil origin/endpoint_sahil
-
This command will confirm to you the current branch:
git branch
-
Start SQL Server in a docker container with:
docker run --cap-add SYS_PTRACE -e ACCEPT_EULA=1 -e MSSQL_SA_PASSWORD=SqlPassword! -p 1444:1433 --name azsql -d mcr.microsoft.com/azure-sql-edge
-
In root directory of the code, run the following commands:
dotnet restore dotnet build
-
In root directory of the code, run the following commands:
dotnet ef migrations add M1 --project ./src/Api/ --startup-project ./src/Api/Api.csproj --msbuildprojectextensionspath .build/obj/Api/ --context ApplicationIdentityDbContext --output-dir Data/Migrations/IdentityDb dotnet ef migrations add M2 --project ./src/Api/ --startup-project ./src/Api/Api.csproj --msbuildprojectextensionspath .build/obj/Api/ --context ApiDbContext --output-dir Data/Migrations/ApiDb dotnet ef database update --project ./src/Api/ --msbuildprojectextensionspath .build/obj/Api/ --context ApplicationIdentityDbContext dotnet ef database update --project ./src/Api/ --msbuildprojectextensionspath .build/obj/Api/ --context ApiDbContext
-
Add the following to the appsettings.Development.json in the Api project:
"JwtSettings": { "validIssuer": "Good Deed Books API", "validAudience": "http://localhost:8001", "expires": 60 }, "SECRET": { "key": "GoodDeedBooks1234GoodDeedBooks1234" }
-
Go to the src/Api folder and start the WebAPI app with:
dotnet watch
-
Hit this endpoint in order to populate the database with some sample data: http://localhost:8001/api/administration/setup. Thereafter, test endpoint http://localhost:8001/api/Financials/Accounts
Expected Result when testing endpoint /api/Financials/Accounts
-
In a separate terminal window, go to the src/AccountGoWeb and run the backend ASP.NET Core MVC app with the following command:
dotnet watch
The use of React as a replacement for MVC.
-
Update to the latest versions of
node
npm
-
In a separate terminal window, go to the `src/GoodBooksReact` folder run these commands:
npm install npm run dev
The React app will run. It is a rudimentary frontend menu system and is a work in progress. As at September 2024, it was decided to postpone development of this react app in favor of using Blazor instead.
Set the following database environment variables in production on API Azure site:
- DBSERVER
- DBUSERID
- DBPASSWORD
- DBNAME
The above values are replaced in Startup.cs in the Api project. The connection string is first read from appsettings.json and the appropriate values are then replaced with environment variables.
"ConnectionStrings": {
"DefaultConnection": "Data Source={0};User ID={1};Password={2};Initial Catalog={3};TrustServerCertificate=yes;MultipleActiveResultSets=true;"
}