Coder Social home page Coder Social logo

azure-samples / contoso-real-estate Goto Github PK

View Code? Open in Web Editor NEW
780.0 16.0 475.0 35.69 MB

Intelligent enterprise-grade reference architecture for JavaScript, featuring OpenAI integration, Azure Developer CLI template and Playwright tests.

License: MIT License

TypeScript 10.04% Dockerfile 0.15% Shell 0.14% JavaScript 45.51% HTML 30.52% SCSS 0.67% CSS 7.73% Bicep 5.25%
architecture azd-templates azure cloud angular javascript next serverless strapi stripe

contoso-real-estate's Introduction

page_type languages products urlFragment name description
sample
azdeveloper
javascript
typescript
nodejs
bicep
azure
azure-container-apps
azure-container-registry
azure-cosmos-db
azure-database-postgresql
azure-functions
azure-key-vault
azure-sdks
azure-storage
static-web-apps
entra-id
playwright
vs-code
azure-pipelines
contoso-real-estate
Contoso Real Estate: JavaScript + Enterprise
Intelligent enterprise-grade reference architecture for JavaScript, featuring OpenAI integration, Azure Developer CLI template and Playwright tests.

Enterprise-grade Reference Architecture for JavaScript

This repository contains the reference architecture and components for building enterprise-grade modern composable frontends (or micro-frontends) and cloud-native applications. It is a collection of best practices, architecture patterns, and functional components that can be used to build and deploy modern JavaScript applications to Azure.

Important

The application code is meant to serve as a reference. Please incorporate your security governance, audits and conventions before productionizing.

Open in GitHub Codespaces

Supported Application Scenarios

The following scenarios are part of the application sample

Table of Contents

You can navigate through the documentation using the table of contents below:

Architecture Diagram

Application architecture diagram

Simplified Flow Diagram

flowchart TD
    %%

    subgraph Internet
    Portal[https://portal.contoso.com]
    Blog[https://blog.contoso.com]
    CMS[https://cms.contoso.com]
    Stripe[https://stripe.contoso.com]
    API[https://api.contoso.com]
    end

    subgraph Azure API Management
    APIM(API Gateway)
    end

    subgraph Azure Static Web Apps
    SWA_Angular([Angular])
    end

    subgraph Azure Functions
    Functions([Node.js])
    end

    subgraph Azure Container Apps
    ACA_Next([Next.js])
    ACA_Strapi([Strapi])
    ACA_Stripe([Stripe])
    end

    subgraph Database/Storage
    DB_PostresSQL[(PostgreSQL - Strapi)]
    DB_Mongo[(MongoDB - Portal)]
    Storage([Azure Blob Storage - CMS])
    end

    Portal --> SWA_Angular -- "portal.contoso.com/api/**" --> APIM -- "portal.contoso.com/api/**" --> Functions

    Blog -- "blog.contoso.com" --> ACA_Next -. "Strapi API" .-> ACA_Strapi

    CMS -- "cms.contoso.com" --> ACA_Strapi
    ACA_Strapi -- "read/write" ----> DB_PostresSQL -- "read only" --> Functions
    ACA_Strapi -- "upload" --> Storage

    API --> APIM -- "api.contoso.com" --> Functions <-- "read/write" --> DB_Mongo

    Stripe ---> APIM -- "stripe.contoso.com" --> ACA_Stripe <-. "validate payment (through APIM)" .-> Functions

    %% Portal
    linkStyle 0 stroke:pink
    linkStyle 1 stroke:pink
    linkStyle 2 stroke:pink

    %% Blog
    linkStyle 3 stroke:blue
    linkStyle 4 stroke:blue
    linkStyle 5 stroke:blue

    %% CMS
    linkStyle 5 stroke:red
    linkStyle 6 stroke:red
    linkStyle 8 stroke:red

    linkStyle 7 stroke:lime
    linkStyle 9 stroke:lime
    linkStyle 10 stroke:lime
    linkStyle 11 stroke:lime

Components

Frontend

  • Angular - The Portal application used to view and book listings.
  • Next.js - The Blog application used to view and create blog posts.
  • Playwright - The end-to-end testing of the Portal application.
  • Azure Static Web Apps - The hosting of the Portal application.

Backend

In order use API Management, please set the boolean flag useAPIM on the main bicep file to true. This will provision the API Management instance and configure the APIs to use it. Please note that this will incur additional costs and the provisioning process may take up to 40 minutes.

DevOps

Developer tools

Development environment

This project is optimized for use with GitHub Codespaces, a development environment hosted in the GitHub cloud. Here is how to get started:

  1. Fork this repository.
  2. Create a new GitHub Codespaces from your fork. This will automatically provision a new Codespaces with all the required dependencies preinstalled and configured.
  3. Open the terminal and run npm install && npm start to start the development servers. Note: Codespaces will show a series of windows on the right side of the screen while starting all servers. This is normal and expected.
  4. Once all dev servers have started, the following URLs will be available:
Application URL Port
Portal https://YOUR-REPO-4280.preview.app.github.dev:4280 4280
Blog https://YOUR-REPO-3000.preview.app.github.dev:3000 3000
Strapi CMS https://YOUR-REPO-1337.preview.app.github.dev:1337/admin 1337
Serverless API https://YOUR-REPO-7071.preview.app.github.dev:7071/api/ 7071
Stripe API https://YOUR-REPO-4242.preview.app.github.dev:4242 4242

Note: The URLs above are just examples. The URLs will be different for your fork. The ports however will be the same.

AI chatbot integration

The Contoso Real Estate application can be integrated with an AI support chatbot built using Azure OpenAI.

For more details about enabling the chatbot integration, see this section.

Usage costs

Github Codespaces usage is billed either to an organization or to the user creating it. There are limits to the number of concurrent codespaces you can create or run, so here are a few things to keep in mind:

Project structure

The project is using npm workspaces. The project structure is as follows:

  • packages/ - contains all the packages
    • api - contains the serverless Azure Functions API.
    • portal - contains the Angular web portal.
    • blog - contains the Next.js blog.
    • blog-cms - contains the Strapi CMS.
    • docs - contains the Developer Guide website
    • stripe - contains the Stripe webhook.
    • testing - contains the Playwright tests.

Deploy to Azure

Prerequisites

This project uses GitHub Codespaces as the main development environment. The following steps assume you are using GitHub Codespaces. If you are not using GitHub Codespaces, you can open the project in a Dev Container locally following the instructions here.

Deploy to Azure

This project uses Azure Developer CLI (azd) to provision infrastructure, package, and deploy the application to Azure. Running the following commands will get you started with deployment.

# Login to azd. Only required once per install.
# If the command fails, try using the --use-device-code flag
azd auth login

# Provision infrastructure and the azd development environment
azd provision

# Package the app using the environment variables in .azure/env + deploy the code on Azure
azd deploy

The --use-device-code is used to log in by using a device code instead of a browser, this may resolve any browser issues while logging in. For more information on when & why to use flags, check here

If you encounter issues with the Azure Developer CLI, please open an issue here.

Important: It is mandatory to run these azd commands in this order. Provisioning first will create the azd development environment and outputs the .env file with the required environment variables. Packaging will package the application using some of the environment variables from the .env file.

Deployment region: Your deployment may fail if the region you selected is unavailable for provisioning specific resources. We recommend using westeurope as your target region since that has been currently validated for all services.

Configure CI-CD

Use the following command to configure the CI-CD pipelines:

azd pipeline config --auth-type client-credentials

Clean up resources

When you are done, you can delete all the Azure resources created with this template by running the following command:

azd down

Developer guidelines

The project has a standalone Developer Guide defined under packages/docs and implemented as an interactive website using the Docusaurus platform. To learn more about it, go here.

Want to help?

Want to file a bug, contribute some code, or improve the documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the list: community-help.

contoso-real-estate's People

Contributors

aaronpowell avatar alidotdeveloper avatar anfibiacreativa avatar cmendible avatar cyaxaress avatar dannyk05 avatar dfberry avatar diberry avatar error9098x avatar glaucia86 avatar gmausdev avatar grand-rick001 avatar jaykay24 avatar john0isaac avatar jongio avatar juliamuiruri4 avatar kelvink96 avatar krishnaanaril avatar layzeedk avatar manekinekko avatar nitya avatar richardrigutins avatar shatilkhan avatar sinedied avatar sumitparakh avatar surya-v-28 avatar tanmai2002 avatar thivy avatar v-xuto avatar xingsy97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

contoso-real-estate's Issues

[Task] Create Strapi instance

  • Use the azd template to add Strapi to the repo (depends on #61)
  • Define the data models required for the blog
  • Create sample content for local testing

[Chore][Api][Portal] Create isomorphic library with models and business logic

Models and they typings are shared between API and Portal, so we should extract them into a seperate package (as we're using a workspaces monorepo) and include also shared business logic, like price calculation.

  • Create package common
  • Extract models types into this package and use them in API/Portal
  • Extract common business logic and use it in API/Portal

[Chore] Evaluate the deployment of Strapi on Azure

Strapi currently has docs on deploying to an Azure AppService, which can be found here: https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/azure.html#paas-deployment-guides

We need to evaluate if those docs are still accurate, and if we should update them to use Azure components that have been released since the docs were created, namely Container Apps for hosting and azd as a template scaffolding option.

[Task] Create an azd template for setup of Strapi resources

Following the guide outlined on the docs for azd, a template needs to be created that will include the following Azure resources

  • PostgreSQL or MySQL database options*
  • Azure Container Registry
  • Azure Container Apps
  • AppInsights

It should also boostrap the Dockerfile that is required for deploying to Container Apps.

The template shouldn't include Strapi itself, instead it should expect that the user will either already have Strapi in their repo (we'll dictate conventions to where it should be) or they will run the create-strapi-app command themselves.

* Ideally there will be a prompt option on whether they want to use PostgreSQL or MySQL, but due to limitations in the template engine, we'll have to dictate a database option as default, but there will be both resource sets in there for the user to change if desired.

[Feat] Implement AZD template (Bicep)

  • angular - swa
  • cosmos db
  • postgresql
  • keyvault
  • azure functions
  • app services
  • monitoring
  • container apps env
  • strapi - container apps
  • storage account
  • nextjs - container apps
  • stripe - container apps
  • apim (#118)
  • vnet (#118)
  • redis (blocked)
  • event grid (pending)
  • azure cdn (pending)

[Feat] Implement App Insights

In scope of this task:

  • Configure App Insights in Azure backend
  • Configure App Insights in the Frontend (portal) (won't implement in this issue)
  • Document App Insights

[Task] Create template for deploying Next.js on SWA

Following the azd docs, create a template that will scaffold the resources needed to deploy Next.js to SWA.

Note: The template won't include Next.js itself, it is expected that the user will either have an existing Next.js codebase, or will run create-next-app themselves.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.