Stock price fetching web app with a monorepo microservices architecture.
A Web App that displays stock prices, made to study microservices architecture with RabbitMQ and Docker containerization.
stocks
├─ .dockerignore
├─ .gitignore
├─ api
│ ├─ Dockerfile
│ ├─ __init__.py
│ ├─ main.py
│ └─ requirements.txt
├─ common
│ ├─ __init__.py
│ └─ rmq.py
├─ docker-compose.yaml
├─ fetcher
│ ├─ Dockerfile
│ ├─ __init__.py
│ ├─ main.py
│ └─ requirements.txt
├─ frontend
│ ├─ Dockerfile
│ ├─ index.html
│ ├─ package-lock.json
│ ├─ package.json
│ ├─ postcss.config.cjs
│ ├─ public
│ │ └─ stocks.svg
│ ├─ src
│ │ ├─ App.css
│ │ ├─ App.tsx
│ │ ├─ assets
│ │ │ └─ stocks.svg
│ │ ├─ components
│ │ │ ├─ Dashboard.tsx
│ │ │ ├─ Main.tsx
│ │ │ ├─ Navbar.tsx
│ │ │ ├─ SelectedStock.tsx
│ │ │ ├─ StockList.tsx
│ │ │ └─ StockListItem.tsx
│ │ ├─ index.css
│ │ ├─ main.tsx
│ │ └─ vite-env.d.ts
│ ├─ tailwind.config.cjs
│ ├─ tsconfig.json
│ ├─ tsconfig.node.json
│ └─ vite.config.ts
├─ test.py
└─ tests
├─ __init__.py
├─ test_api_main.py
├─ test_common_rmq.py
└─ test_fetcher_main.py
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Essentials:
Docker
Docker Compose (If it didn't come with your docker version)
------------------------------
Optionals:
Git (To clone the project)
Python 3.11* (If you want to run the tests)
* Python version I tested with, but might work just fine with older versions.
How to setup your dev env
Clone repo & cd into it
git clone https://github.com/hoxas/stocks && cd stocks
Run docker-compose.yaml
docker compose up
Docker Compose should build the apps images and run the containers for you, wait a couple seconds to make sure everything is up as it should.
Access the web app on the default url through your browser of choice:
http://localhost:3000
Test the app by typing a ticker in the search bar and pressing enter
To run the automated tests you're gonna need python installed locally with venv. (Recommended and tested with Python 3.11)
Simply run scripts/tests.py and it will create a venv in the repo folder for you, install requirements in the venv and run the tests.
python3.11 scripts/tests.py
Virtually 100% coverage as I left out the "if __name__ == __main__" testing because I saw no real need for it and also chose not to add it to the coverage ignore.
Module | statements | missing | excluded | coverage |
---|---|---|---|---|
api/__init__.py | 0 | 0 | 0 | 100% |
api/main.py | 43 | 1 | 0 | 98% |
common/__init__.py | 0 | 0 | 0 | 100% |
common/rmq.py | 21 | 0 | 0 | 100% |
fetcher/__init__.py | 0 | 0 | 0 | 100% |
fetcher/main.py | 25 | 1 | 0 | 96% |
tests/__init__.py | 0 | 0 | 0 | 100% |
tests/test_api_main.py | 105 | 0 | 0 | 100% |
tests/test_common_rmq.py | 41 | 0 | 0 | 100% |
tests/test_fetcher_main.py | 38 | 0 | 0 | 100% |
Total | 273 | 2 | 0 | 99% |
Add notes about how to use the system.
- Typescript - Front-end Language
- React - Front-end Framework
- Tailwind - CSS Framework
- Vite - Front-end Build Tool
- Python - Back-end Language
- Flask - Gateway API Framework
- Redis - Gateway API Caching
- RabbitMQ - Message Broker for Back-end Apps
- @hoxas - Project Creator