ACE API has three layers (socket-io, open-api, and Flask) , all served from ./run.py. When the flask app receives a request it goes through the layers for handling any incoming request.
- If the incoming request protocol matches socket-io, it gets handled first
- Next, it matches the request against open-api protocol
- Finally, any unhandled request gets forwarded to flask
We use socket-io to stream real-time events. NATs messages are forwarded via socket-io.
The api server is self-documenting! The documentation page can be accessed from /api/v1/ui after running run.py script
Read more about open-api specs
Flask module for serving static files build from ace-ui
- Install python
- Install venv
- Install the python dependency by running
pip install -r requirement
from the project root directory. You may want to create a virtual environment first
running local python code for development
python3 -m venv env
source env/bin/activate
pip install -r requirement.txt
python run.py
for test
pytest ./test
There are three components to python application
- run.py contains API related code. We use open-api for linking the python functions with the API
endpoints. Please see openapi/ace_api.yaml for how the API was designed. Furthermore, when
you run the python code, an UI for the API is available on
http://[root_url]/api/v1/ui
- ace_db.py contains code for linking database with the API. For database, we are using sqlite3.
- Tests direcotry contains test code for python module. We try our best to write test code here.
The code for ACE web interface is located on web-app directory. This was build using a base react template from https://github.com/hanyuei/react-material-admin (MIT licensed)
Additional documentation for ACE-web app is available on ./web-app/README.md React framework was used for building the user interface.
for dev
git clone <repository-url>
cd ace-api/web-app
# change into the new directory
npm install
npm start # will run the app and open it on your browser window. Note that your system must resolve hostnames such as nats_server
for test
npm run test
for Production
npm run build
cd build
# start a static server serving ./build dir, eg node serve/http-server or serve in express using express.static
serve -s build
The front end is written in Javascript and typescript and packaged with NodeJS. Code structure is the following:
- The javascript code is located on web-app/src directory
- Code for each individual page is on web-app/src/pages
- Code for components that makes up the pages is on web-app/src/components. Here component for individual page may have their sub folders.
We use N, Grafana, Nats.io and several other components in the background to run this system.
- ../nginx directory contains configuration on how the reverse proxy was setup for this application.
- ../grafana directory contains configuration on Grafana. See the docker-compose.yaml to learn about how these directories are mounted to nginx and Grafana containers.