1- # Contibutor guide
1+ # Contributor guide
22
33[ ![ GitLab Pipeline Status] ( https://gitlab.com/devpro-labs/software/keeptrack/badges/main/pipeline.svg )] ( https://gitlab.com/devpro-labs/software/keeptrack/-/pipelines )
44[ ![ Build Status] ( https://dev.azure.com/devprofr/open-source/_apis/build/status/keeptrack-ci?branchName=main )] ( https://dev.azure.com/devprofr/open-source/_build/latest?definitionId=26&branchName=main )
55
6- ## Design
6+ Follow this steps to run/debug/develop the application on your machine.
77
8- This design of API has been inspired by the [ Hexagonal Architecture ] ( https://blog.octo.com/en/hexagonal-architecture-three-principles-and-an-implementation-example/ ) .
8+ For an environment, look at [ operations.md ] ( docs/operations.md ) .
99
10- NuGet Packages:
10+ ## Design
1111
12- - [ MongoDB C# Driver ] ( https://www.mongodb.com/docs/drivers/csharp/current/ )
12+ The application source code is in the following .NET projects:
1313
14- ## Requirements
14+ Project name | Technology | Project type
15+ ---------------------------|------------|------------------------------
16+ ` BlazorApp ` | ASP.NET 10 | Blazor Server web application
17+ ` Common.System ` | .NET 10 | Library
18+ ` Domain ` | .NET 10 | Library
19+ ` Infrastructure.MongoDb ` | .NET 10 | Library
20+ ` WebApi ` | ASP.NET 10 | Web application (REST API)
21+ ` WebApi.Contracts ` | .NET 10 | Library
1522
16- - [ .NET 10.0 SDK] ( https://dotnet.microsoft.com/download )
17- - MongoDB 8.2 database
18- - Local server
23+ The application is using the following .NET packages (via NuGet):
1924
20- ``` bash
21- cd D:/Programs/mongodb-8.2/bin
22- md log
23- md data
24- mongod --logpath log/mongod.log --dbpath data --port 27017
25- ```
25+ Name | Description
26+ --------------------|--------------------
27+ ` FirebaseAdmin ` | Firebase
28+ ` MongoDB.Bson ` | MongoDB BSON
29+ ` MongoDB.Driver ` | MongoDB .NET Driver
30+ ` Scalar.AspNetCore ` | OpenAPI web UI
2631
27- - [ Docker] ( https://hub.docker.com/_/mongo/ )
32+ ## Requirements
33+
34+ 1 . [ .NET 10.0 SDK] ( https://dotnet.microsoft.com/download )
2835
29- ``` bash
30- docker run --name mongodb -d -p 27017:27017 mongo:8.2
31- ```
36+ 2 . MongoDB database
3237
33- - [ MongoDB Atlas ] ( https://cloud.mongodb.com/ ) cluster
38+ Several options:
3439
35- - Database indexes
40+ - Local server
41+
42+ ``` bash
43+ cd D:/Programs/mongodb-8.2/bin
44+ md log
45+ md data
46+ mongod --logpath log/mongod.log --dbpath data --port 27017
47+ ```
48+
49+ - [Docker](https://hub.docker.com/_/mongo/)
50+
51+ ` ` ` bash
52+ docker run --name mongodb -d -p 27017:27017 mongo:8.2
53+ ` ` `
54+
55+ - [MongoDB Atlas](https://cloud.mongodb.com/) cluster
3656
37- ``` bash
38- docker run --rm --link mongodb -v " $( pwd) /scripts" :/home/scripts mongo:8.2 bash -c " mongo mongodb://mongodb:27017/keeptrack /home/scripts/mongo-create-index.js"
39- ```
57+ 3. IDE: Rider, Visual Studio, Visual Studio Code
4058
41- ## How to configure
59+ # # Configuration
4260
43- ### Web API
61+ # ## Web API appsettings
4462
4563Key | Description
4664------------------------------------------| --------------------------
@@ -49,10 +67,14 @@ Key | Description
4967
5068This values can be easily provided as environment variables (replace " :" by " __" ) or by configuration (json).
5169
52- Template for ` src/Api /appsettings.Development.json ` :
70+ Template for ` src/WebApi /appsettings.Development.json` :
5371
5472` ` ` json
5573{
74+ " AllowedOrigins" : [
75+ " http://localhost:5207" ,
76+ " https://localhost:7042"
77+ ],
5678 " Authentication" : {
5779 " JwtBearer" : {
5880 " Authority" : " https://securetoken.google.com/<firebase-project-id>" ,
@@ -62,43 +84,54 @@ Template for `src/Api/appsettings.Development.json`:
6284 }
6385 }
6486 },
87+ " Features" : {
88+ " IsScalarEnabled" : true,
89+ " IsHttpsRedirectionEnabled" : false
90+ },
6591 " Infrastructure" : {
6692 " MongoDB" : {
6793 " ConnectionString" : " mongodb://localhost:27017" ,
68- "DatabaseName" : " keeptrack "
94+ " DatabaseName" : " keeptrack_dev "
6995 }
7096 },
7197 " Logging" : {
7298 " LogLevel" : {
73- "KeepTrack " : " Debug" ,
74- "Withywoods " : " Debug"
99+ " Default " : " Debug" ,
100+ " KeepTrack " : " Debug"
75101 }
76102 }
77103}
78104` ` `
79105
80- ### Blazor Server App
106+ # ## Blazor Server App appsettings
81107
82- TODO
108+ Key | Required | Default value
109+ ----------------------------------------| ----------| --------------
110+ AllowedHosts | false | " *"
111+ Features:IsHttpsRedirectionEnabled | false | true
112+ Firebase:WebAppConfiguration:ApiKey | true | " "
113+ Firebase:WebAppConfiguration:AuthDomain | true | " "
114+ Firebase:WebAppConfiguration:ProjectId | true | " "
115+ Firebase:ServiceAccount | true | " "
116+ Logging:LogLevel:Default | false | " Information"
117+ Logging:LogLevel:Microsoft.AspNetCore | false | " Warning"
118+ WebApi:BaseUrl | true | " "
83119
84- ## How to build
120+ # # Run
85121
86122` ` ` bash
87123dotnet restore
88- dotnet build
89- ```
90124
91- ## How to debug
125+ dotnet build
92126
93- ``` bash
94127# run the API (https://localhost:5011/)
95128dotnet run --project src/WebApi
96129
97130# run the Blazor WebAssembly web app (https://localhost:5021)
98131dotnet run --project src/BlazorApp
99132` ` `
100133
101- ## How to test
134+ # # Tests
102135
103136For integration tests, to manage the configuration (secrets) you can create a file at the root directory called ` Local.runsettings` or define them as environment variables:
104137
@@ -107,7 +140,7 @@ For integration tests, to manage the configuration (secrets) you can create a fi
107140< RunSettings>
108141 < RunConfiguration>
109142 < EnvironmentVariables>
110- <AllowedOrigins__0 >http://localhost:4200 </AllowedOrigins__0 >
143+ < AllowedOrigins__0> http://localhost:5207 < /AllowedOrigins__0>
111144 < Infrastructure__MongoDB__ConnectionString> mongodb://localhost:27017< /Infrastructure__MongoDB__ConnectionString>
112145 < Infrastructure__MongoDB__DatabaseName> keeptrack_integrationtests< /Infrastructure__MongoDB__DatabaseName>
113146 < Authentication__JwtBearer__Authority></Authentication__JwtBearer__Authority>
@@ -130,31 +163,9 @@ Or in Rider, in "File | Settings | Build, Execution, Deployment | Unit Testing |
130163
131164Set KESTREL_WEBAPP_URL to target a specific instance (not use web app test instance).
132165
133- And execute all tests (unit and integration ones):
134-
135- ``` bash
136- dotnet test --settings Local.runsettings
137- ```
138-
139- ## How to deploy
140-
141- - Add the outbound IP to the MongoDB Atlas cluster
142- - Add the application url to Firebase domains
143- - Create web project in Firebase and grab ids to be set to environment.ts file
144- - Create a GitHub OAuth application ([ firebase.google.com] ( https://firebase.google.com/docs/auth/web/github-auth ) ,
145- [ github.com] ( https://github.com/settings/applications/new ) )
146- - Add URLs in Azure web app CORS page
147-
148- ## How to operate
149-
150- - Backup MongoDB database
151-
152- ``` bash
153- docker run --rm -it --workdir=/data --volume $( pwd) :/data mongo:8.2 /bin/sh -c " mongodump --uri mongodb+srv://<USER>:<PASSWORD>@<CLUSTER>.<PROJECT>.mongodb.net/test"
154- ```
155-
156- - Restore MongoDB database
166+ # # Container images
157167
158168` ` ` bash
159- docker run --rm -it --workdir=/data --volume $( pwd) :/data mongo:8.2 /bin/sh -c " mongorestore --uri mongodb+srv://<USER>:<PASSWORD>@<CLUSTER>.<PROJECT>.mongodb.net"
169+ docker build . -t devprofr/keeptrack-blazorapp:local -f src/BlazorApp/Dockerfile
170+ docker build . -t devprofr/keeptrack-webapi:local -f src/WebApi/Dockerfile
160171` ` `
0 commit comments