Skip to content

MangoInstantMessenger/MangoMessengerAPI

Repository files navigation

Mango Messenger Web API

Mango Messenger Logo

Description

Mango Messenger is an opensource instant messaging system implemented using .NET Core and Angular frameworks. In general, mango messenger is considered to be a bachelor's degree project. Bachelor's degree has been successfully completed by the team of three students on 10-02-2022. However, it is worth to continue progress on the project pursuing another predefined goals.

How it works

Main goals of the project

  • Implementation of simple, maintainable, safe and scalable code base following the KISS and YAGNI software development principles
  • To maintain the code quality using static code analyzers such as ReSharper, SonarCloud where SonarCloud analysis is a part of the CI/CD pipeline with further publication of the quality gate results
  • To setup proper IDE configurations and code style rules using editor config and StyleCop extensions
  • To maintain high (> 70%) code coverage using unit tests, integration tests with ongoing publication of the coverage report to the Azure DevOps workflow statistics
  • To implement layered architecture where each layers is a separate project responsible for single part of the application. For example, the Domain layer is responsible for the business logic and validates itself
  • To implement productive, quick and safe development cycle. It is mainly about organization of the CI/CD process using Azure DevOps and Azure pipelines so that each pull request to be validated and tested. Moreover, the CD (Continuous Deployment) must be confirmed manually be designated person
  • To implement and deploy IaaC using Terraform
  • To implement cryptographic protocol that allows End-to-end (E2E) encryption using confidential clients
  • To implement semantic versioning as part of CI/CD pipeline
  • To implement and deploy ARM templates utilizing Azure Pipelines and Github Actions
  • To explain release and versioning strategy
  • To implement CD pipeline to deploy app to IIS as part of Windows VM
  • To implement CD pipeline to deploy app to Nginx as part of Linux VM
  • To implement pen testing using OWASP ZAP tool
  • To implement various deployment patterns like Blue-Green, Canary etc
  • To implement release flow according to the documentation: PDF

Infrastructure diagram and details

infra

  • Windows app service plan F1-tier
  • Windows app service
  • Azure StorageV2 account with LRS redundancy
  • Azure storage account
  • Azure SQL server
  • Azure SQL database S0 instance with 10 database transaction units [Serverless]
  • Azure KeyVault
  • Application Insights

Screenshots

Chats

./img/chats.png

Contacts

./img/contacts.png

Settings

./img/settings.png

Build and run the project

Required Software

Run docker compose

  • docker-compose build
  • docker-compose up

Run in debug mode

  • Install NVM: https://github.com/coreybutler/nvm-windows
  • Install NodeJS 16.13.1 using NVM & PowerShell as Administrator: nvm install 16.13.1
  • Use NodeJS 16.13.1 using NVM via PowerShell as Administrator: nvm use 16.13.1
  • Check NodeJS installed properly (should be 16.13.1): node -v
  • Check NPM installed properly (should be 8.7.0): npm -v
  • Go to the project folder: cd MangoAPI.Client
  • Restore node modules: npm ci
  • Install Angular CLI globally: npm install -g @angular/[email protected]
  • Open PowerShell as Administrator and type: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
  • Check that Angular CLI installed properly: ng version
  • Build project for development using Angular CLI: ng build
  • Run database container: docker run -e "SA_PASSWORD=x2yiJt!Fs" -e "ACCEPT_EULA=y" --name "mango-mssql-db" --hostname "mango-mssql-db" -p "1433:1433" -d mcr.microsoft.com/mssql/server:2022-latest
  • Run azurite storage emulator:
    • npm install -g azurite
    • azurite --silent --location c:\azurite --debug c:\azurite\debug.log
  • Upload mock images from ./img/seed_images/* to local Azure Blob container
  • Restore .NET packages: cd .. & dotnet restore
  • Run the .NET web API: dotnet run
  • Navigate to the swagger: https://localhost:5001/swagger/index.html
  • Navigate to the root url: https://localhost:5001/app

PS: Sometimes it is not convenient for come people to use docker container as database. In this case, you can set db connection string environment variables for web app and integration tests. For example,

  • DatabaseUrl: Data Source=DESKTOP-CK5PEBD;Initial Catalog=MANGO_DEV;Integrated Security=true;TrustServerCertificate=True;
  • IntegrationTestsDatabaseUrl: Data Source=DESKTOP-CK5PEBD;Initial Catalog=MANGO_INTEGRATION_TESTS;Integrated Security=true;TrustServerCertificate=True;
  • How to set environment variables in Windows

In case of localhost HTTPS certificate issues: https://stackoverflow.com/a/67182991

Run integration tests

  • Run MsSQL database container: docker run -e "SA_PASSWORD=x2yiJt!Fs" -e "ACCEPT_EULA=y" --name "mango-mssql-db" --hostname "mango-mssql-db" -p "1433:1433" -d mcr.microsoft.com/mssql/server:2022-latest
  • Install Azurite: https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=npm
    • npm install -g azurite
    • azurite --silent --location c:\azurite --debug c:\azurite\debug.log
    • Upload mock images from ./img/seed_images/* to local Azure Blob container

Technology stack

  • SDK: .NET 6
  • Frameworks: ASP .NET, Angular
  • Persistence:
    • Database: MS SQL Server
    • ORM: Entity Framework Core
    • Storage: Azure Blob Storage
  • Authorization: ASP .NET Identity, JWT Bearer
  • Business Logic:
    • MediatR
    • Fluent Validation
    • AutoMapper
  • Presentation:
    • API Documentation: OpenAPI (Swagger)
    • Realtime Communication: SignalR
    • Frontend Development: Angular
  • Unit and Integration Testing: XUnit, FluentAssertions
  • Code Quality Tools: SonarQube
  • Containerization: Docker
  • Continuous Integration: Azure Pipelines, GitHub Actions
  • Continuous Deployment: Azure Pipelines, GitHub Actions, Azure DevOps, Azure App Service
  • Programming languages: C#, SQL, TypeScript
  • Tools & IDE: Visual Studio, Rider, VS Code, WebStorm, SMSS, Postman

Powered by JetBrains

Mango Messenger Logo

On March 14, 2023 Mango Messenger has received the JetBrains Open Source License for 1 year with opportunity to extend next years if opensource conditions met. These licenses are properly shared between active contributors. Thanks to JetBrains from the whole team of Mango Messenger.

Useful Links

Badges

Workflow Status
Build Angular Build Angular
Build Test Coverage Build Test Coverage
Run CNG DH Handshake Run CNG DH Handshake
Run OpenSSL DH Handshake Run OpenSSL DH Handshake
Azure Pipelines Build Status
Code coverage Coverage Status
Quality gate Quality Gate Status

Logo Attribution

Icons made by Freepik from www.flaticon.com