Skip to content

coldarse/SND.SMP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SND SMP

Introduction

This SMI Portal is created to replace the V1 version for Signature Mail. It is a revamped version, which consists of the frontend (Angular 17), backend (Dotnet 8 Core C#), a background worker to process heavy tasks, a MySQL as database, and a dockerized FileServer called ChibiSafe. All these are running on their respective images using Docker (Except for the DB). The recommended server for this project is a Linux Server due to its flexibility, ease of use, and affordability.

SMP Information

  • Architecture: Monolithic
  • Database: MySQL
  • Framework:
    • Backend: C# DotNet8
    • Frontend: Angular Framework 17
  • Source Control: GitHub Enterprise
  • Targeted Deployment Hub: Linux Server | Ubuntu 22.04 Jammy
  • Recommended IDEs:
    • Backend: Visual Studio 2022 (DotNet8 Support) / Visual Studio Code
    • Frontend: Visual Studio Code
  • Requirements:
    • Node.js
    • MySQL
    • DotNet8
    • Docker

Architecture

image

Database:

  • Uses MySQL

Backend and Background Worker:

  • Uses Docker to containerize the image.

Frontend:

  • SMI Portal is containerized as an instance
  • Will be accessed using a public URL

ChibiSafe File Server:

  • Docker to containerize the image.

Guide

Below are the steps to guide you to run this project in the local environment.

Installing MySQL 8.0

This SMD Portal will be using MySQL as its database storage. Here are the steps to install MySQL on your local development machine.

  1. Head to Community DL Page (dev.mysql.com) to download the installer. We are using the current latest version 8.0.36. Select the Windows x86-64bit installer.

image

  1. Click on No thanks, just start my download to start your download.

image

  1. Run the installer and accept and allow changes, then select Custom and click Next.

image

  1. Select these product to be installed and click the arrow to the right.
    • MySQL Server 8.0.36 - X64
    • MySQL Workbench 8.0.36 - X64
    • MySQL Shell 8.0.36 - X64
    • MySQL Router 8.0.36 - X64

image

  1. Confirm the list of product to be installed and then click Execute.

image

  1. Wait for the installation to complete then click Next.

image

  1. Then click Next to proceed to configure MySQL Server.

image

  1. Use default settings then Next.

image

  1. Proceed Next again.

image

  1. Input your password. In this case my password is abcd1234.

image

  1. Rename the services name if you wish or else just use default then Next.

image

  1. Grant full access and proceed.

image

  1. Click on Execute to apply all those configuration you just did.

image

  1. After configuration successfully applied, click on Finish.

image

  1. Then click on Next and proceed to use default configuration for MySQL Router setup.

image

  1. You may check Start MySQL Workbench after setup to run the application after click on Finish to finalize MySQL installation.

image

  1. Or you use Windows Key + S to open search on Windows and type in MySQL to open it.

image

  1. Click on Local instance MySQL80. Additionally you may rename the connection name by right click Edit Connection to suit your project naming criteria.

image

  1. Enter your password that we just configured just now. You may tick Save password in vault and the password will auto saved so you do not need to enter everytime you access MySQL.

In our case, the username is root and the password is abcd1234.

image

  1. Click on Schemas and your database list will be listed on the left side.

image

Installing GitHub Desktop

The source control for this project is using GitHub Enterprise. If you do not have an account, go to GitHub Signup Page to create an account. Remember to use your company account. After you have created an account, request access to GitHub enterprise from your manager and provide your account name.

The guide below will be to install GitHub Desktop on your local machine and pull the project from the Hub.

  1. Head over to this link to download the installer for GitHub Desktop.

image

  1. Click on Skip this step to proceed.

image

  1. Configure your information.

image

  1. Once installed, you will see the screen below.

image

  1. Go to File > Options or Ctrl + , to open GitHub Desktop Settings.

image

  1. Head to Accounts and Sign-in to GitHub.com.

image

  1. It will prompt you sign in using your browser. Click Continue with browser.

image

  1. Key in the Username/Email address and Password of the account linked to the company’s GitHub Enterprise and click Sign in

image

  1. After you sign in, it will redirect back to GitHub Desktop. If you have accepted to join GitHub enterprise from your company email, you will see coldarse with the available repos under it. Select "coldarse/SND.SMP" and click Clone.

image

  1. Create a local path for the repo to clone to and click Clone.

image

  1. After the cloning process is done, you will see the screen as below.

image

  1. To open the project, got to Repository and select Show in Explorer or Ctrl + Shift + F.

image

  1. This will open up the project folder in File Explorer. Double click the .sln file to open the solution in Visual Studio 2022.

image

  1. Your project solution’s Solution Explorer should look something like that.

image

Installing Docker Desktop

In this project, we will utilize Docker to deploy our applications.

Below are the steps to install Docker Desktop on your local machine.

  1. Head over to https://www.docker.com/products/docker-desktop/ and download Docker Desktop for windows

image

  1. Click on the .exe file to open the installer.

image

  1. You will see the Configuration page, you may uncheck Add shortcut to desktop if you do not wish for it to, but make sure to check Use WSL 2, this will enable you to run both Windows and Linux containers on your Windows machine. Click Ok.

image

  1. The installer will now start installing Docker Desktop. The installation will take a while.

image

  1. After the installation is complete, it will prompt you to restart your machine. Click Close and restart.

image

  1. After your machine has restarted, Docker Desktop will automatically pop up its Service Agreement. You may read through the agreement if you wish and select Accept.

image

  1. If you have not previously configured Docker on your machine or have not run any linux related VMs before, you will be prompted to update/install WSL kernel. Follow the link and you will be brought the Step 4 in the link.

image

  1. Click on the link to download the installer for the latest WSL kernel.

image

  1. Click on the .msi file to open the installer.

image

  1. You will be prompted a pop-up to install the WSL. Click Next.

image

  1. It will be a quick installation. Click Finish.

image

  1. Use Windows Key + S to open search on Windows and type in Windows PowerShell and Run As Administrator.

image

  1. Type in the command wsl --set-default-version 2 to set the default version of WSL.

image

  1. Open Docker Desktop if it’s not already open and you shall see Docker Desktop Starting and you shall see a green bar at the bottom left when it has started.

image image image

Setting up ChibiSafe File Server

This project uses a file server called ChibiSafe, which provides its own authorization, APIs, and documentation to store any files uploaded to the server for easy retrieval and keepsake.

It uses Docker to run so in this setup, a docker-compose.yml file will be used to create a container instance in your own local machine to host this file server.

  1. Navigate to SND.SMP > chibisafe, and within it will contain the docker-compose.yml file.

  2. The file should contain the following.

version: "3.7"

services:
  chibisafe:
    image: chibisafe/chibisafe:v.5.6.10
    container_name: chibisafe
    volumes:
      - ./database:/home/node/chibisafe/database:rw
      - ./uploads:/home/node/chibisafe/uploads:rw
      - ./logs:/home/node/chibisafe/logs:rw
    ports:
      - 24424:8000
    restart: always
  1. To explain this YAML file simply, it is the requirements for making the container run properly.

  2. As you can see under the services tab, we are creating a service called chibisafe with the image that will be pull from the ChibiSafe's DockerHub Repository.

  3. We are naming the container name to be chibisafe.

  4. In the volumes section, we are creating 3 essential directories:

  • database: This is the DB for the file server.
  • uploads: This is the place where it will store the files uploaded to the server.
  • logs: This directory contains the logs generated by the file server.
  1. This file server runs on port 24424 by default, which will route to the port 8000 internally.

  2. We are also setting the restart to always to auto-restart whenever it crashes. This will make sure the file server is always up.

  3. To run this on your local device, assuming you have already installed and configured Docker to your usage, we are going to open up PowerShell and head to this directory.

  4. To run this, simply run the command docker compose up -d.

  5. The parameter -d is to make sure the container is running in the background.

  6. You shall see it begin to pull the image from the ChibiSafe Repository (if you don't have the image on your local machine)

  7. And when its done pulling, it will start on its own.

image

  1. If you see the container has been started like the image above, you can now head over to link and you will see the page below.

image

  1. On the top right corner, click Login / Register.

image

  1. In the Username and Password key in admin on both and click Sign In.

image

  1. You are now logged in to the file server as an admin.

image

  1. You can select the Credentials menu under Account to change your admin password.

image

  1. This project uses the admin account, so to use this we will need the key for the APIs to verify. Click on Request new API key and you will be prompted that this will overwrite the old key, select Confirm to generate.

image

image

  1. Hover over the textbox to show your generated key and copy it.

  2. If you have done the database migration, you will need to insert this into the applicationsettings table.

  3. Head over to MySQL and locate the applicationsettings table. Right click and Select Rows

image

  1. Insert/Update the below 2 records in this table if you do not already have them.
  • ChibiURL : http://localhost:24424/api/
  • ChibiKey : {YourGeneratedToken}

image

  1. On the bottom right corner, click Apply and Apply in the prompt to execute this query for change.

image

image

Installing node version manager

Node Version Manager (NVM), as the name implies, is a tool for managing Node versions on your device.

NVM allows you to install different versions of Node, and switch between these versions depending on the project that you're working on via the command line.

To download, go to nvm-windows. The current latest version as of today (April 2024) is 1.1.12.

  1. Scroll down and click on the Download Now! button.

image

  1. Then scroll down and click on nvm-setup.exe under Assets.

image

  1. Complete the installation wizard. When done, you can confirm that nvm has been installed by running nvm -v on Command Prompt (CMD).

image

  1. Run this command nvm install 20.9.0 to install nodejs version 20.9.0 which compatible with our current project version.

image

  1. After installation succeeded, run this command nvm use 20.0.0 to use the version you just installed.

image

  1. To check current version, run nvm current.

image

EF Core Migration to MySQL

This project already had a build in ef core migration script pre-written. All you need to do is just run the projects and everything will be done automatically.

  1. Expand the src folder then expand SND.SMP.Migrator and finally click on appsettings.json

image

  1. Comment the live server by adding // on the start of the code then copy the code below at a new line and save it.
 "Default": "server=localhost;port=3306;database=SMPDb;uid=root;pwd=abcd1234;"

image

  1. On middle top of your visual studio, there is a drop down list for projects to run. Choose SND.SMP.Migrator.

image

  1. Then click on the start button located at right of the drop down list.

image

  1. A command prompt will then pop out and ask do you want to perform this migration. Type Y then enter.

image

  1. After that wait for the migration to complete and then press ENTER to exit.

image

  1. Close the command prompt.

image

  1. Head to MySQL Workbench and connect to your database.

image

  1. You will notice that on your left, your database had created.

image

Setting up swagger

  1. Expand the src folder then expand SND.SMP.Web.Host and finally click on appsettings.json

image

  1. Comment the live server by adding // on the start of the code then copy the code below at a new line and save it.
 "Default": "server=localhost;port=3306;database=SMPDb;uid=root;pwd=abcd1234;"

image

  1. On middle top of your visual studio, there is a drop down list for projects to run. Choose SND.SMP.Web.Host.

image

  1. Then click on the start button located at right of the drop down list.

image

  1. Wait for the swagger website to launch itself. This will serve as the prove that you had successfully setup swagger.

image

Setting up Angular (UI)

To setup Frontend, we will be using Visual Studio Code. You can use Microsoft Visual Studio too to run angular too.

  1. Launch Visual Studio Code.

image

  1. Go to File > Open Folder or Ctrl+K + Ctrl+O to open folder.

image

  1. Navigate to your project folder and search for angular folder then Select Folder.

image

  1. Visual Studio Code will load your angular project folder.

image

  1. Right click any of the file and then Open in Integrated Terminal.

image

  1. After that enter npm install to install all the necessary packages.

image

  1. If you are having npm ERR! issue, this is due to dependency issue. You can just ignore the error with npm install --force command.

image

  1. Then, after downloaded relevant packages, start the project by typing yarn start.

image

  1. [Optional] If you encounter error as shown from images below, it is due to your yarn.lock content does not match with your package.json else skip to step 13.

image

  1. [Optional] Ctrl+C to stop the terminal and then right click yarn.lock files and delete it.

image

  1. Next, type in yarn to generate a new yarn.lock file.

image

  1. After finish rebuilding yarn.lock type in yarn start to build and start your angular. Wait for it to finish compile. It may take a while.

image

  1. When Visual Studio Code has done building the project, click on http://localhost:4200 and it will open up in your default browser.

image

  1. This is the login page. The id is admin and password is 123qwe.

image

  1. You have successfully setup the frontend. Test out the CRUD of your services to see if they are working properly.

image

About

Signature Mail Portal

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •