Skip to content

yagggi/python_assignment

 
 

Repository files navigation

Financial

This project fetch stock price data, store parsed data into local db, and provide APIs for query.

Tech Stacks

  • storage: MySQL:8.0 is one of the top choices for RDBMS, it's reliable and extensible.
  • web framework: Flask is a popular lightweight Python web framework, which is suitable for this assignment.
  • SQL builder: SQLAlchemy 's SQL Expression Language is flexible to use.
  • MySQL client for Python: PyMySQL is implemented in pure Python, it's easy to install in some system.
  • object (de)serialization: marshmallow is a Python library that converts complex data types to native Python data types and vice versa, it can help reduce code duplication when serialize/deserialize objects.
  • environment variable loader: python-decouple is a tool to load env vars from .env or ini file.
  • HTTP library: requests to make HTTP requests.

How to run this project

  1. Clone this repo to local machine and enter project directory
    >>git clone [email protected]:fakepoet/python_assignment.git && cd python_assignment
  2. Generate .env file with .env.example and replace ALPHA_VANTAGE_API_KEY with yours (if you don't have one, you can apply for free from here)
    cp .env.example .env
  3. Run project via docker-compose
    docker-compose up -d
    Initial data is fetched with above command, if you want to manual update data, please run below command:
    docker exec financial-app python get_raw_data.py
  4. Verify status of containers
    docker ps -f name=financial-
    If you can see two containers with name financial-app / financial-db, then project is running properly.
  5. Test API
    curl -X GET 'http://localhost:5000/api/financial_data'

Manage secret keys

Local development

Secret keys for local development can be stored in .env file, as long as .env is included in .gitignore, it should not be included in repo history.

For safety concerns, you can also add extra protection via password management tools like 1Password, which can turn plain text into secret references

Production

In production environment, it's better to store & use secret via secret management services like Kubernetes secret or AWS secrets manager.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.7%
  • Dockerfile 1.9%
  • Shell 1.4%