Code Monkey home page Code Monkey logo

ners-verify's Introduction

NERS powered by Verify

Welcome to the Non-business Expenses Report System, your microservice for track expenses not related to commercial transactions.

Below will be detailed steps to have the local environment setup or trough docker.

Setup environment

Requirements

Initial system requirements

Install dependencies

By default, the dependencies are managed with Poetry(installation instructions).

From the root directory you can install all the dependencies with:

$ poetry install

Then you can start a shell session with the new environment with:

$ poetry shell

Next, open your editor at ./app/ (instead of the project root: ./), so that you see an ./app/ directory with your code inside. That way, your editor will be able to find all the imports, etc.

Important

Make sure your editor uses the environment you just created with Poetry.


Local development

  • The stack used for develop the services:

    • api: FastAPI.
    • database: PostgreSQL object-relational database system.
    • proxy: A reverse proxy and load balancer for HTTP and TCP-based applications with Traefik.
  • Start the stack with Docker Compose:

docker-compose up -d

Now you can open your browser and interact with these URLs:

To check the logs, run:

docker-compose logs

To check the logs of a specific service, add the name of the service, e.g.:

docker-compose logs api

Authentication

Endpoints are behind authentication, so in order to successfully request you need to provide an API KEY in the request header in form of Bearer token. For the purpose of simplicity the API KEY is any UUID, as long as follows the expected format will be valid.

e.g.

curl -X 'GET' \
  'http://localhost/api/v1/staff/<staff_id>/refund' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer d344f870-0843-4fd0-9f63-f1bc77d99c60'

On the swagger page will be available a button for Authorization, click on it for set a global API KEY that will be used across all endpoints.


Testing

If your stack is already up and running you just want to run the tests, you can use:

docker-compose exec -T api make test

Important

If you are not in detach mode while execute the docker-compose execute this command in a separate terminal.


Migrations

Alembic is the database migration tool used for the application. As during local development your app directory is mounted as a volume inside the container, you can also run the migrations with alembic commands inside the container and the migration code will be in your app directory (instead of being only inside the container). So you can add it to your git repository.

  • Start an interactive session in the api container:
$ docker-compose exec api bash

If you created a new model in ./app/models/, make sure to import it in ./app/db/base.py, that Python module (base.py) that imports all the models will be used by Alembic. Any update to existent models will be automatically recognize by alembic.

  • After changing a model, inside the container, create a revision, e.g.:
$ alembic revision --autogenerate -m "Add column last_name to User model"
  • After creating the revision, run the migration in the database (this is what will actually change the database):
$ alembic upgrade head

ners-verify's People

Contributors

yhbarzaga avatar

Watchers

 avatar

ners-verify's Issues

Add initial project scaffolding

Description

As a user
I want to be able to pull the project and have it up an running

Acceptance Criteria

  1. Project initial structure is complete
  2. Project can be pulled and executed

Update README.md file

Description

As a user
I want to be able to follow README file instructions and have the application up and running locally

Add service provider for OCR Api

Description

As a user
I want to be able to expose a service intended to user a provider for OCR

Acceptance Criteria

  1. Add generic implementation for OCR provider
  2. Add Verify as OCR provider

Add docker configuration to project

Description

As a user
I want to be able to pull the project and using docker setup the configuration on my local environment

Acceptance criteria

  1. Add Dockerfile and docker-compose to orchestrate configurations
  2. Once docker-compose command is execute api and database are properly configured.

Add database tables and related models

Description

As a user
I want to be able to store information on a persistent storage in order to fetch it later

Acceptance criteria

  1. Create tables(and db models) for Staff, Document and DocumentsType(lookup table)

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.