Skip to content

How to setup FairPlayCombined?

Eduardo Fonseca edited this page Nov 13, 2024 · 36 revisions

FairPlayCombined has been implemented using .NET Aspire.

Third-Party Services Pre-Requisites

The applications in the FairPlay category make use of a variety of external services, some of these services require you to create an account in order to use them.

Open AI

Configure your Open AI Key and store in somewhere safe, you will need it later: https://platform.openai.com/account/api-keys

Google Gemini

Get your key here: https://ai.google.dev/gemini-api/docs/api-key

Azure Open AI

You will need to have a Microsoft Azure subscription.

Azure Open AI documentation: https://learn.microsoft.com/en-us/azure/ai-services/openai/

Apply for Azure Open AI access: https://learn.microsoft.com/en-us/azure/ai-services/openai/overview#how-do-i-get-access-to-azure-openai

Azure Video Indexer

This also requires you to have an Azure Subscription.

Azure Video Indexer Documentation: https://learn.microsoft.com/en-us/azure/azure-video-indexer/

Azure Content Safety

Azure Content Safety documentation: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/

SendGrid

For production scenarios, the platform use of SendGrid for sending emails, you can create your SendGrid account through the Azure Portal. You will still need to create SendGrid API Key to be able to send email.

For Development scenarios, you can configure the app to just use MailDev.

Pre-Requisites

  • Install the latest version of Docker Desktop.
  • Install latest version of Visual Studio Preview.
  • Install the .NET SDK version that matches the one in the global.json file.
  • Create and configure Desktop Application in Google Cloud Console and download the "OAuth 2.0 Client ID" file. You will need the values later for the configuration secrets prefixed with "GoogleAuth".
  • Install the latest version of SQL Server and create a new database. Publish the database from the "FairPlayCombinedDb" project.
  • Download the "Generated humans" database: https://generated.photos/humans. Extract it a folder of your choice. Copy the images accordingly into a folder with the structure:
    • HumansImages
      • Male
        • Male Image 1
        • Male Image 2
      • Female
        • Female Image 1
        • Female Image 2

image

To make the process easier you can make use of "ML.NET Model Builder", which is integrated in Visual Studio. Learn how to use it here: https://dotnet.microsoft.com/en-us/apps/machinelearning-ai/ml-dotnet/model-builder

Setup Visual Studio Solution

  • Set the startup project to be "FairPlayCombinedSln.AppHost".
  • Setup User Secrets for project "FairPlayCombinedSln.AppHost".
    • You will need to set the values for the following secret keys:
      • GoogleAuthClientId
      • GoogleAuthProjectId
      • GoogleAuthUri
      • GoogleAuthTokenUri
      • GoogleAuthProviderCertUri
      • GoogleAuthClientSecret
      • GoogleAuthRedirectUri
      • FairPlayCombinedDb:
        • Database connectionstring.
      • AddFairPlayDating:
        • true/false. Indicates if the AppHost should start the respective project.
      • AddFairPlayDatingTestDataGenerator:
        • true/false. Indicates if the AppHost should start the respective project.
      • AddFairPlayTube:
        • true/false. Indicates if the AppHost should start the respective project.
      • AddFairPlayShop:
        • true/false. Indicates if the AppHost should start the respective project.
      • AddCitiesImporter:
        • true/false. Indicates if the AppHost should start the respective project.
      • AddFairPlatAdminPortal:
        • true/false. Indicates if the AppHost should start the respective project.
      • AddFairPlaySocial:
        • true/false. Indicates if the AppHost should start the respective project.
      • AddFairPlaySocialTestDataGenerator:
        • true/false. Indicates if the AppHost should start the respective project.
      • AddLocalizationGenerator:
        • true/false. Indicates if the AppHost should start the respective project.
      • AddFairPlayBudget:
        • true/false. Indicates if the AppHost should start the respective project.
      • HumansPhotosDirectory
      • UseSendGrid
        • true/false. Use true for using SendGrid, false for using MailDev.
      • SMTPServer: Only required when using SendGrid. Leave it blank if using MailDev.
      • SMTPUsername: Only required when using SendGrid, value will be "apikey". Leave it blank if using MailDev.
      • SMTPPassword: Only required when using SendGrid, value will be the actual value of your API Key. Leave it blank if using MailDev.
      • SMTPPort: 25
      • UseSSLForSMTP: false
      • EmailFrom: The value that will be shown in the from when sending messages, when using SendGrid, it must be the same you configured in SendGrid's portal.

Note: For now, we are not using SSL for sending emails, though we will use it in the future before releasing the platform for production purposes.

**NOTE: **If you want to use a container-based database, then, include the following flags in your user secrets:

  • "UseDatabaseContainer": true
  • "Parameters:FairPlayCombinedDbServer-password": "REPLACE WITH YOUR PASSWORD"

NOTE: Before running the apps, make sure to start Docker Desktop.

For the first run, only set the admin portal to true, run it, create a new user and login, then navigate to "ConfigurationSecretsManage", once there you have to setup the rest of the configuration.

image

Once you have configured everything you can stop the app, set true for the flag of the projects you want to run and use the other applications.

NOTE: Platform make use of data-driven localization, the tables are empty by default. In order to fill the data, you must set the system to execute the project "FairPlayCombined.LocalizationGenerator", by setting the "AddLocalizationGenerator" flag to true, it makes use of Azure Open AI service, you must make sure, you have previously already configured the services from the Admin Portal.

Generating Test Data

Due to their nature, some of the FairPlay applications functionality can be used only when there are multiple systems, FairPlayCombined has consider that and has integrated some Test Data generators to make your development process easier.

Generating FairPlayDating Test Data

  • Configure the App Host to have only the flag "AddFairPlayDatingTestDataGenerator" set to true.
  • Make sure you already have the "HumansPhotosDirectory" correctly setup.
  • Run the AppHost.
  • Navigate to the logs. You will eventually see something like this: image

image

Ignore the GeoData XML errors.

Running Automated Tests

  • In Visual Studio, right click the project "FairPlayCombined.AutomatedTests" and select "Manage User Secrets".
  • Copy and paste the contents from the template file: "AutomatedTestsUserSecretsTemplate.json".
  • Complete the configuration with your own resources.
  • Start Docker Desktop.
  • In Visual Studio Main Menu select: "Test", and then "Run All Tests"., Test Explorer will be opened Tests will be started.

**Note: **Tests using paid services will not run by default. Files containing tests using paid services will be inside a if/endif precondition:

#if Debug_Enable_Paid_Tests

Your Code

#endif

To run the tests, you must set the solution configuration to "Debug_Enable_Paid_Tests" instead of "Debug"

Clone this wiki locally