Skip to content

ita-social-projects/YIF_Backend

Repository files navigation

This is Your IT Future Backend

About the project

This is a project that provides applicants with an opportunity to get acquainted with the list of educational institutions that provide education in our region. Applicants can get detailed information about the available specialties that are required for admission, training materials etc.


Main parts of the project and technologies

This project contains 3 main parts: client frontend, backend and database. Frontend part of the project is at https://github.com/ita-social-projects/YIF_Frontend

Let's take a closer look at the technologies of each part.

Client Frontend - some kind of unicorn magic is used here

Backend - ASP.NET Core 3.1, Doker, FluentValidation, Swagger, Automaper, Identity Server, Azure, Jenkins.

Database - MS SQL SERVER, Microsoft Azure.

Code quality - SonarCloud.

Testing - XUnit

SDLC - Scrum/Kanban


How to start the project locally.

Clone or download the project from https://github.com/ita-social-projects/YIF_Backend

  • Install ASP.NET Core 3.1

  • Install Entity Framework

  • Create local database from https://github.com/ita-social-projects/YIF_Backend

  • Open project in Visual Studio or enter command "dotnet run [-c|--configuration ] [-f|--framework ] [--force] [--interactive] [--launch-profile ] [--no-build] [--no-dependencies] [--no-launch-profile] [--no-restore] [-p|--project ] [-r|--runtime <RUNTIME_IDENTIFIER>] [-v|--verbosity ] [[--] [application arguments]]"


How to run the project with docker-compose locally

Installation Prerequisites:

Git Docker for Mac, Docker for Windows, or Docker Engine

Run application in containers:

To run this application, first git clone the project.

You should add appsettings.json to project (folder YIF_Backend/YIF_Backend). Check: 1)the connection string in appsettings.json "ConnectionStrings": { "DefaultConnection": "Server=yifsql,1433;Database=master;User Id=SA;Password=YIF_Backend_DB_MyKeyOnlyInMyHeart;" }

  1. Seeder in Startup.cs #region Seeder SeederDB.SeedData(app.ApplicationServices); #endregion

Then run these commands to start the containers: cd YIF_Backend docker-compose up --build

Then you can access the web api at http://localhost:5000/swagger/index.html

Stop containers:

Run command to stop the containers: docker-compose stop

Delete containers:

Run command to delete the containers: docker-compose down

Details

docker-compose.yml file

Note that there are two images - one for the web api (yifbackend) and one for SQL Server (yifsql). The yifsql image uses mcr.microsoft.com/mssql/server:2017-latest as the base. It is the SQL Server image for running on Linux. Whenever you start a mcr.microsoft.com/mssql/server:2017-latest container, you need to pass in some environment variables:

ACCEPT_EULA: "Y" SA_PASSWORD: "YIF_Backend_DB_MyKeyOnlyInMyHeart"

For this demo the password is set to 'YIF_Backend_DB_MyKeyOnlyInMyHeart' but you can change it if you want. Make sure you also change it in appsettings.json configuration if you do though!

Note that the server name is 'yifsql'. This is the name that the SQL Server container is known by the web container as on the container network. Note the name of the DB is 'master'. You can change this to whatever you want. Entity Framework will attempt to create the DB if it doesnt already exist.


How to run the Front-End docker and Back-End docker as one container

Clone YIF_Frontend and YIF_Backend in the same folder.

git clone https://github.com/ita-social-projects/YIF_Backend.git
git clone https://github.com/ita-social-projects/YIF_Frontend.git

Configuration

Configure as per instructions in the YIF_Frontend and YIF_Backend repositories:

For YIF_Backend

Uncomment:

  1. File YIF.Core.Data/Seaders/SeederDB.cs, line context.Database.Migrate();
  2. File YIF.Backend/Startup.cs, line SeederDB.SeedData(app.ApplicationServices)

Add files appsettings.json and appsettings.Testing.json to YIF_Backend/YIF_Backend. Ensure that the following Code is uncommented.

"DefaultConnection":"Server=yifsql, 1433;Database=YITF;User Id=SA;Password=YIF_Backend_DB_MyKeyOnlyInMyHeart;"

For YIF_Frontend

Add .env file to the YIF_Frontend(.env is not presented in the github repository, you need to ask one of the developer for it)

Create docker-compose.yml file on the same folder level as YIF_Backend and YIF_Frontend.

.
├── YIF_Backend             ← cloned YIF_Backend repository
├── YIF_Frontend            ← cloned YIF_Frontend repository
├── docker-compose.yml

Paste below code in the docker-compose.yml file.

version: "3.8"
services:
    yif_frontend:
        build:
            dockerfile: Dockerfile.development
            context: ./YIF_Frontend
        ports:
        - "3000:3000"
        container_name: yif_frontend
        restart: always
    yif_backend:
        build:
            dockerfile: Dockerfile.VM
            context: ./YIF_Backend
        container_name: yif_backend
        image: smethan/yifbackend:latest
        networks: 
            - yif
        ports:
            - "5000:3000"
        depends_on:
            - yif_sql
        restart: always
    yif_sql:
        image: mcr.microsoft.com/mssql/server:2017-latest
        container_name: yif_sql
        networks: 
            - yif
        ports: 
            - "1433:1433"
        environment:
            ACCEPT_EULA: "Y"
            SA_PASSWORD: "YIF_Backend_DB_MyKeyOnlyInMyHeart"
            MSSQL_PID: "Express"
        restart: always
        volumes: 
            - yifsqldata:/var/opt/mssql/data
networks:
    yif:
        name: yif
        driver: bridge
volumes: 
    yifsqldata:

Run the following command on the same level: docker-compose up --build

If the project doesn't open automatically, open your browser and type:

http://localhost:3000 

How to run the project with docker-compose on Azure

Prerequisites:

Azure account Virtual machine Ubuntu18.04 Allow port: 5000 on Virtual machine Git (https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) Docker Engine on Ubuntu (https://docs.docker.com/engine/install/ubuntu/) Docker-compose (https://docs.docker.com/compose/install/)

Run application in containers

Look above ## How to run the project with docker-compose locally

Then you can access the web api at http://ip:5000/swagger/index.html

Team

@team @team @team @team @team @team

@team @team @team @team @team @team @team

@team @team @team @team @team @team @team


FAQ


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages