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.
- 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
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.
Below are the steps to guide you to run this project in the local environment.
This SMD Portal will be using MySQL as its database storage. Here are the steps to install MySQL on your local development machine.
- 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.
- Click on
No thanks, just start my download
to start your download.
- Run the installer and accept and allow changes, then select Custom and click Next.
- 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
- Confirm the list of product to be installed and then click Execute.
- Wait for the installation to complete then click Next.
- Then click Next to proceed to configure MySQL Server.
- Use default settings then Next.
- Proceed Next again.
- Input your password. In this case my password is
abcd1234
.
- Rename the services name if you wish or else just use default then Next.
- Grant full access and proceed.
- Click on Execute to apply all those configuration you just did.
- After configuration successfully applied, click on Finish.
- Then click on Next and proceed to use default configuration for MySQL Router setup.
- You may check
Start MySQL Workbench after setup
to run the application after click on Finish to finalize MySQL installation.
- Or you use
Windows Key + S
to open search on Windows and type in MySQL to open it.
- Click on
Local instance MySQL80
. Additionally you may rename the connection name by right click Edit Connection to suit your project naming criteria.
- 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 isabcd1234
.
- Click on
Schemas
and your database list will be listed on the left side.
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.
- Head over to this link to download the installer for GitHub Desktop.
- Click on Skip this step to proceed.
- Configure your information.
- Once installed, you will see the screen below.
- Go to File > Options or
Ctrl + ,
to open GitHub Desktop Settings.
- Head to Accounts and Sign-in to GitHub.com.
- It will prompt you sign in using your browser. Click Continue with browser.
- Key in the
Username
/Email
address andPassword
of the account linked to the company’s GitHub Enterprise and click Sign in
- 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.
- Create a local path for the repo to clone to and click Clone.
- After the cloning process is done, you will see the screen as below.
- To open the project, got to Repository and select
Show in Explorer
orCtrl + Shift + F
.
- This will open up the project folder in File Explorer. Double click the
.sln
file to open the solution in Visual Studio 2022.
- Your project solution’s Solution Explorer should look something like that.
In this project, we will utilize Docker to deploy our applications.
Below are the steps to install Docker Desktop on your local machine.
- Head over to https://www.docker.com/products/docker-desktop/ and download Docker Desktop for windows
- Click on the
.exe
file to open the installer.
- 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.
- The installer will now start installing Docker Desktop. The installation will take a while.
- After the installation is complete, it will prompt you to restart your machine. Click Close and restart.
- 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.
- 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.
- Click on the link to download the installer for the latest WSL kernel.
- Click on the
.msi
file to open the installer.
- You will be prompted a pop-up to install the WSL. Click Next.
- It will be a quick installation. Click Finish.
- Use
Windows Key + S
to open search on Windows and type in Windows PowerShell and Run As Administrator.
- Type in the command
wsl --set-default-version 2
to set the default version of WSL.
- 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.
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.
-
Navigate to
SND.SMP > chibisafe
, and within it will contain thedocker-compose.yml
file. -
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
-
To explain this YAML file simply, it is the requirements for making the container run properly.
-
As you can see under the
services
tab, we are creating a service calledchibisafe
with the image that will be pull from the ChibiSafe's DockerHub Repository. -
We are naming the container name to be
chibisafe
. -
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.
-
This file server runs on port 24424 by default, which will route to the port 8000 internally.
-
We are also setting the
restart
toalways
to auto-restart whenever it crashes. This will make sure the file server is always up. -
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.
-
To run this, simply run the command
docker compose up -d
. -
The parameter
-d
is to make sure the container is running in the background. -
You shall see it begin to pull the image from the ChibiSafe Repository (if you don't have the image on your local machine)
-
And when its done pulling, it will start on its own.
- 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.
- On the top right corner, click
Login / Register
.
- In the
Username
andPassword
key inadmin
on both and clickSign In
.
- You are now logged in to the file server as an admin.
- You can select the
Credentials
menu underAccount
to change your admin password.
- 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, selectConfirm
to generate.
-
Hover over the textbox to show your generated key and copy it.
-
If you have done the database migration, you will need to insert this into the
applicationsettings
table. -
Head over to MySQL and locate the
applicationsettings
table. Right click andSelect Rows
- Insert/Update the below 2 records in this table if you do not already have them.
ChibiURL
:http://localhost:24424/api/
ChibiKey
: {YourGeneratedToken}
- On the bottom right corner, click
Apply
andApply
in the prompt to execute this query for change.
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.
- Scroll down and click on the Download Now! button.
- Then scroll down and click on
nvm-setup.exe
under Assets.
- Complete the installation wizard. When done, you can confirm that nvm has been installed by running
nvm -v
on Command Prompt (CMD).
- Run this command
nvm install 20.9.0
to install nodejs version 20.9.0 which compatible with our current project version.
- After installation succeeded, run this command
nvm use 20.0.0
to use the version you just installed.
- To check current version, run
nvm current
.
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.
- Expand the
src
folder then expandSND.SMP.Migrator
and finally click onappsettings.json
- 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;"
- On middle top of your visual studio, there is a drop down list for projects to run. Choose
SND.SMP.Migrator
.
- Then click on the start button located at right of the drop down list.
- A command prompt will then pop out and ask do you want to perform this migration. Type
Y
then enter.
- After that wait for the migration to complete and then press ENTER to exit.
- Close the command prompt.
- Head to MySQL Workbench and connect to your database.
- You will notice that on your left, your database had created.
- Expand the
src
folder then expandSND.SMP.Web.Host
and finally click onappsettings.json
- 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;"
- On middle top of your visual studio, there is a drop down list for projects to run. Choose
SND.SMP.Web.Host
.
- Then click on the start button located at right of the drop down list.
- Wait for the swagger website to launch itself. This will serve as the prove that you had successfully setup swagger.
To setup Frontend, we will be using Visual Studio Code. You can use Microsoft Visual Studio too to run angular too.
- Launch Visual Studio Code.
- Go to File > Open Folder or
Ctrl+K + Ctrl+O
to open folder.
- Navigate to your project folder and search for angular folder then Select Folder.
- Visual Studio Code will load your angular project folder.
- Right click any of the file and then Open in Integrated Terminal.
- After that enter
npm install
to install all the necessary packages.
- If you are having npm ERR! issue, this is due to dependency issue. You can just ignore the error with
npm install --force
command.
- Then, after downloaded relevant packages, start the project by typing
yarn start
.
- [Optional] If you encounter error as shown from images below, it is due to your
yarn.lock
content does not match with yourpackage.json
else skip to step 13.
- [Optional]
Ctrl+C
to stop the terminal and then right clickyarn.lock
files and delete it.
- Next, type in
yarn
to generate a newyarn.lock
file.
- After finish rebuilding
yarn.lock
type inyarn start
to build and start your angular. Wait for it to finish compile. It may take a while.
- When Visual Studio Code has done building the project, click on http://localhost:4200 and it will open up in your default browser.
- This is the login page. The id is
admin
and password is123qwe
.
- You have successfully setup the frontend. Test out the CRUD of your services to see if they are working properly.