Code Monkey home page Code Monkey logo

food-web-app's Introduction

Food Ordering Service ASP.NET Core .NET MAUI

This repository contains an ASP.NET Core WebAPI application that implements JWT Authentication, a .NET MAUI application for administrative frontend that consumes the protected WebAPI.

Project structure

repository
|__src
|    |__Foody -> web api project
|    |__client -> maui project
|    |__.gitignore
|__.gitignore
|__ReadME.md

Getting Started

Some requirement and workloads to install:

Setup

We need to setup a few things first before running the projects.

  • Database : PostgreSQL database
  • Distributed Cache : Redis distributed

Setup Postgres Database

Pull postgresql image from hub

docker pull postgres

Create a container instance

docker run --name postgresql -e POSTGRES_PASSWORD=<yourpassword> -p 5432:5432 -d postgres

Run psql

docker exec -it postgresql psql -U postgres

psql commands

First we'll need to create an new role. The role would have login and database creation priviledges.

CREATE ROLE devuser WITH LOGIN CREATEDB PASSWORD '<yourpassword>';

Switch to the new user

\c postgres devuser

Create the database

CREATE DATABASE foody;

NOTE: You can run the command \l to view all existing databases

Setup Redis for Caching

Create a redis container instance

docker run --name redis-cache -p 6379:6379 -d redis

Clone the repository

Open a command prompt(windows) or terminal(mac) and enter the command:

git clone https://github.com/coderBane/food-web-app.git

Configure the WebAPI

Before we can run the project we need to configure a few things for the web api. Open the Foody.WebApi.csproj file and delete the UserSecretsId property.

User-Secrets

Run the command:

dotnet user-secrets init

Generate a random string using this website random Create a new file 's.json' and populate it with the following

{
    "JwtConfig": {
        "Secret": "<generatedstring>",
        "ExpiryTimeFrame": "00:01:00"
    },
    "WatchDog": {
        "Username": "<yourusername>",
        "Password": "<yourpassword>"
    },
    "Redis": "localhost",
    "Postgres": "Server=localhost:5342;Database=foody;User Id=devuser;Password=<devuserpassword>;Integrated Security=true;Pooling=true;",
    "UserPW": "<yourpassword>"
}

Set the user secrets

cat ./s.json | dotnet user-secrets set

NOTE: You can delete the s.json file

Apply Database Migrations

We need to create the tables in the database.

dotnet ef --startup-project ../Foody.WebApi database update

Run the Projects

We can now run the projects

ASP.NET Core WebAPI

launch without swagger

dotnet run 

launch with swagger UI

dotnet watch

.NET MAUI

food-web-app's People

Contributors

coderbane avatar souravsk avatar

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.