Design and Structure

The structure of the project is designed to scale as much as possible. The structure focuses heavily on automation and growth. This allows us to not have to worry about adding on to the website in the future phases. It's as easy as writing your changes however you want and then watching everything propagate down the system.

The site is kept inside of a virtual environment. This is a common pattern in Python that allows for multiple different versions of the same software to be installed on the system at any given point of time. This makes it easy to continue working on the site regardless of the status of other projects' use of libraries. For example, if Flask were suddenly to do a major overhaul and it was no longer compatible with older versions, we could easily keep developing in the old version but still start new projects in the new version. Furthermore, similar to npm, virtualenv allows us to easily share which libraries we are using through the notion of a requirements.txt file. This way, to have the same development environment anywhere, all you have to do is pull the github repo and run the code in the makefile. Anytime a library is updated, added, or removed, the requirements.txt file should be changed and make install should be run again.

The Flask project is structured in such a way that allows greater structure and readability of the files. Additionally, it is setup so that it can be installed as a module which helps add on to the project. The project is structured so that all code is contained in one folder and project level things like the makefile are at the root of the project. Documentation, such as the UML diagram goes into the docs/ folder. Personal information like configuration files are kept in the instance/ folder. Resources and tool information is kept in the resources/ folder. Tests and other information related to testing is in the tests/ folder. All source code is kept in the idb/ folder. The only code kept at this level is the makefile, used for automation, and setup.py which is used to install our project as a module.

The source code is structured in a functional manner with the static/ folder used for keeping things that never change like stylesheets, a templates/ folder for our Jinja2 templates, a views/ folder that processes routing for the various aspects of the site. Finally, there is an __init__.py file that starts up the application, registers the various Flask blueprints, and starts listening for connections. One of the things that our project needs as an inevitability of installing our project as a module is to set an environment variable that tells the system where to route Flask. This is in Linux by the following command export FLASK_APP=idb/__init__.py.

  • To install our project, simply run make install. To run as a developer, simply run make run but on a production server this installation guide was followed.
  • To update the production website or restart it, simply run make restart-prod.
  • Config files allow our project to understand what kind of environment they are in. The default config is kept at instance/default_config.py but the application will attempt to find a config file first at instance/application.pybefore defaulting.

results matching ""

    No results matching ""