kamacharovs / aiof-api

All in one finance API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Overview

All in one finance API

Build Status

Documentation

aiof API overall documentation

Application

On a high level, the API is a CRUD application for aiof data. It is based on a multi-tenant pattern with user_id. This is enforced by the interface ITenant which gets dependency injected. Even though User A is authenticated and authorized (via JWT), they can't access data for User B who is the same, authorization-wise, to user A. Thus, the authentication and authorization process flow is as follows:

  • Is User Authenticated?
  • Is User Authorized to access this Endpoint? Are they in the correct Role?
  • Does access to the data the User is trying to get need to be controlled? If yes
  • Then, user_id gets extracted from the JWT claim and EF Core uses QueryFilters to filter the data a User can access - in the current scenario, only their own

How to run it

In order to fully run it locally, the recommended way is to use docker-compose. That pulls down all the Docker images needed and you will have the full microservices architecture locally in order to get a JWT from aiof-auth and add it to your requests to this API

Local

From the root project directory

dotnet run -p .\aiof.api.core\

Or change directories and run from the core .csproj

cd .\aiof.api.core\
dotnet run

Make API calls to

http://localhost:5001

Docker

There are 2 ways to run it through Docker. One is pulling the remote image and the other is building the image locally

Docker local

Build the image from Dockerfile.local

docker build -t aiof-api:latest -f Dockerfile.local .

You can now use your locally built aiof-api:latest in any docker-compose.yml configuration. This is extremely helpful when you change logic in the API and you need to run this custom code locally for other microservices depending on it

Docker remote

Pull the latest image from Docker Hub

docker pull gkama/aiof-api:latest

Run it

docker run -it --rm -e ASPNETCORE_ENVIRONMENT='Development' -p 8000:80 gkama/aiof-api:latest

Make API calls to

http://localhost:8000/

(Optional) Clean up none images

docker rmi $(docker images -f dangling=true -q)

Docker compose

From the project root directory

docker-compose up

EF Core migrations

Migrations are managed in the ef-migrations branch

dotnet ef migrations add {migration name} -s .\aiof.api.core -p .\aiof.api.data
dotnet ef migrations script -p .\aiof.api.data
dotnet ef migrations script {migration name} -s .\aiof.api.core -p .\aiof.api.data
dotnet ef migrations remove -s .\aiof.api.core -p .\aiof.api.data

About

All in one finance API

License:MIT License


Languages

Language:C# 100.0%Language:Dockerfile 0.0%