Giter Site home page Giter Site logo

kompassen-2.0's Introduction

Kompassen 2.0

Getting started

Prerequisities

To start developing you need to install the following dependencies.

Contact

If you have any issues or anything is unclear, please feel free to contact Jonas Sjödin at [email protected] (2021).

Development

To start developing, open two terminals and run the following commands.

# Terminal 1 - The server
$ cd server && docker compose up -d && yarn && yarn reseed && yarn start

# Terminal 2 - The webapp
$ cd webapp && yarn && yarn start

Web App

The client is a React Typescript web application. It uses Material UI as its main component library. On login it authorizes itself with the Azure AD service. The project structure consists of larger sections in the /src/sections directory, that is a page which can be reached and greeted with the browser. They can also be navigated to with React Router DOM. General components which can be used in multiple sections are available in the /src/components directory and general hooks are available in /src/hooks. Application wide state is handled with Redux and its content is available in /src/reducers.

Server

The server is a NodeJS based express server which communicates with a PostgreSQL backend. The database can be started with docker compose up -d. It can be seeded with yarn reseed which rollbacks the database, migrates the latest table layout and seeds it with dummy data. The server can then be started with yarn start.

Database

The database is built using Knex database migrations which allows for seemless database schema upgrades without requiring manual labour. Schema upgrades should be made by creating a new file (i.e. if 11_create_some_table is the newest, name next file 12_add_column_to_some_table) and not by editing the existing files. If that is done, a manual schema upgrade has to be performed on the production database which is not ideal. So remember, never edit these files if you do not know what you are doing, only create new ones.

When developing you may sometimes want to restart with a fresh development database. This can be done with the following command. It deletes all old project containers and volumes. Then it starts the database, migrates the tables and seeds them and lastly starts the server.

docker compose rm -sf; docker volume rm server_pgdata; docker compose up -d && yarn reseed && yarn start

To access the development postgres database, connect your postgres client to port 15432 and the credentials available in the docker-compose.yml file. You can also use the following command.

docker compose exec postgres psql -U username kompassen2

Server

The express server is configured with a configuration file in the /src/config directory. It consists of a REST API and a Socket IO Websocket API for realt time updates. The /src/handlers directory controls the endpoint handlers and their input validation which is done by the Joi library. The handlers connects to the database with the database functions available in the /src/database directory. Data in /lib/{contants,types.ts} is shared between the server and webapp with the copy_types.sh script which is available in the project root.

Infrastructure

The application is designed to run on Azure and is automatically setup with the Infrastructure as Code tool Terraform. The deployment should NOT be edited manually with az cli or in the cloud portal but by editing the terraform files. If done this way, the production environment will always be reproducible. In the /infrastructure directory there are two subdirectories, /infrastructure/setup and /infrastructure/production. The terraform configuration is split up in these two directories because of their separate use case. The setup directory handles setting up login and CICD funcitonality, such as Azure AD and Github actions secrets. This functionality requires more extensive authorization which we do not want to be available in our CICD pipelines. The production directory handles setting up and configuration of the production code such as the web app, server and database.

Setup

The setup directory creates a service principal, an Azure AD application, a backend storage account for the production terraform configuration and some Github Actions secrets. It can only be applied by Azure users with Owner role. It should not be used to develop the production infrastructure, just to setup a complete new production environment and to initialise the CICD pipelines.

GITHUB_TOKEN=<some_git_token>
TF_VAR_subscription=<some_azure_subscription>

Most developers will never need apply or edit these files. Only do this if you know what you are doing.

If you are setting up a completely new production environment you first need to install the azure CLI az. You can then run the initAzureStorage.sh script which sets up a new resource group and a storage accounts which acts as a backend for the setup Terraform environment. If this script is run with the -d or --delete flag, the terraform state of the setup environment is deleted. Once again, only do this if you really want to remove all production code or know what you are doing.

Production

The production directory sets up the production infrastructure which consists of a Azure Container Registry (ACR), two Azure App Services (backend + frontend) and a Postgres database. It can be run with the Contributer role and its state is automatically applied on each merge to main in CICD pipelines.

If you want to apply the terraform state manually it can be done by running

terraform apply

CICD

CICD is handled with Github Actions. Automatic linting and formatting checks are run on each commit to all branches that aren't main. When something is pushed to or pulled into main, the terraform configuration is applied and the webapp and server containers are built and pushed to production, updating the current production instances.

Azure AD user role assignment

In the Azure console, roles are assigned to users under Azure Active Directory / Enterprise applications. Then find the application "kompassen2-ad" and assign the role under Users and Groups.

kompassen-2.0's People

Contributors

hannes-samskog avatar ipomega avatar victoriacatalan avatar techbecca avatar dependabot[bot] avatar tomaswandahl avatar albinsod avatar omegachristoffer avatar dennisgranberg avatar jonaskop avatar mmmod avatar

Stargazers

 avatar Axel Wickman avatar  avatar Davis Freimanis avatar Mattias Blom avatar Jakob Petersson avatar  avatar  avatar

Watchers

James Cloos avatar  avatar Mirjam Borén avatar  avatar

Forkers

dennisgranberg

kompassen-2.0's Issues

Component- Hantera mina anmälda pass

Protptype: Startskärm SB, box on the right side

Contains the latest performed (?) classes /"pass" the user have done/ made and some info of the event (date/location)
Also contains a button to the other classes/ "pass"- page

Component - Header

Prototype - Everywhere

Top left = navigation to home
Top right is notifications (component) and Profile

Component "Message"

Page "Startskärm SB"

The message shows how many comments there are in the discussion for each class/ (se. "pass")

Note-
Following the logic of the "like"
The message-symbol should not be filled when no messages in disscussion

Component - Text input

A description in the top
Should be able to handle multiple lines of text (expand down)

Move to SQL

The data is very relational, consider move to SQL-db like Postgres

Component- Collection- Class/"Pass"

Prototype: Startskärm SB

  • Contains information of when, where and if it needs a lecturer
  • Component "Like/Heart"
  • Component "Message"
    A headline of what class it is
    Description of the class
  • Tags related to the class
  • A button to fold / unfold the discussion
  • A discussion thread with the possibility to send messages.

Component - Removable box

Prototype - Startskärm SB, see filter box in prototype

A box with text and a "remove- X" at the end to delete said box.

Component - "Like"/ Heart

See prototype - Page "Startskärm SB"

When a user clicks on the unfilled heart, the number next to the heart increases and the heart is filled.
When a user clicks on the filled heart, the number next to the heart decreases and the heart not filled.

  • Note-
    Where do we register the number of "Likes"/"Heart"

Popup

As of now there are several versions of popups, this need be discussed where to differentiate to different components or not ex.

  • 1 button + link (passhållare bekräftelse )
  • 2 buttons + link ("Ställ upp som passhållare)
  • 2 buttons (Är du säker)
  • 2 buttons + text input (Är du säker, plannering av pass)
  • Lägg till ny händelse

Component- Collection - Next competence day

Prototype: Startskärm SB

Contains
Button with text and symbol - component
A selector to show next competence day planed (loaction, day (yyyy-mm-dd), time)
Count down- component
Pie-chart- component

Component - Button with text and symbol

Prototype- Startskärm SB- Right side, at the top of the top 2 info boxes

A button in the top with text, and icon (in that order).
There are two present in prototype ( different colors )

Summary of created class/ "pass"

Prototype: Pass- skapat

A box with the top showing date/location and title

The box shows a summary of the class/ "pass" planned.
It also shows in bottom right if waiting for approval

Component - Breadcrumbs

Prototype: Startskärm SB

Showing the navigation/ depth/ position in the site/application for the user.
Clickable text links to go back to that site/ depth.

Component- Pie-chart

Prototype - Starkskärm SB

Shows the distribution of the different areas of the classes / "pass" that will be held during the competence day.
Showed both in chart and in number on the side

Component - Notifications

A list of notifications.
Top right "Mark all as read"

Bold text is not read.

An image to the left of who is involved
A description of what has happened ex. "liked you post".
A notion of how long time since event happened
An additional button to open the two selections "Marked as read" or "remove"

Component- Collection -Filter

A collection of filters
3 drop down- components
1 search component

Also shows applied filters and the feature to remove them ("Remove applied filter"- issue).

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.