Backend file structure:
Backend/
.circleci/
config.yml
app/
test/
__init__.py
app.py
controller.py
database.py
.gitignore
Dockerfile
README.md
Requierements.txt
The .circleci/config.yml file in the repository branch indicates the
use of CircleCI
for continuous integration.
For better understanding of the config.yaml file structure, please see
circleci-python and
closer description on CI in our Ops documentation
CI-chain.
Package app host the application and runs on http://0.0.0.0:5000.
-
init.py - in Python, if a sub-directory includes a init.py file it is considered a package, and can be imported.
-
app.py - in this module we structure our application, set routes and create the application object as an instance of Flask imported from the flask package.
from flask import Flask
...
app = Flask(__name__)
...
@app.route('/')
...The @app.route decorator creates an association between the URL given as an argument and the function.
-
controller.py - here lays all the logic for each endpoint/route from the
app.py. Onceapp.pyreceives data fromFrontend, it processes data and make queries to the database. -
database.py - this module, establishes connection to database.
def get_db_conn():
connection = client[db_name]
return connectionPrepares collections in "hackernews" database hosted on MongoDB server.
To understand the sequence flow, please see System Sequence Diagram below.

- Passwords hashed with bcrypt.
When running docker-compose up --build Docker builds images automatically
by reading the instructions from a Dockerfile.
Read more detailed about Dockerfile here.
In the Dockerfile, we have specified which tools we want installed on
the Docker image. RUN pip install -r requirements.txt command
will look for the requirements.txt file and install the listed requirements.
requirements.txt:
Flask==0.12.3
pymongo
bcrypt
pytest
flask_httpauth