Migrating/Updating my TinyDB MAC API-Organizing the Project

While I laid out four quick steps in my project, the truth is that steps are never that linear. Instead my project has been conducted in small incremental steps that often jump between creating SqlAlchemy functions and using FastAPI for validation. One thing I wanted to document during this project, was module dependencies. I did some research online and found a tool called pydeps that could help me with that problem. In order to use pydeps you must also install Graphviz. Graphviz’s website provides several different options you can use (I used dnf) and required no configuration once installed.

To begin using pydeps, I created a virtual environment and pip installed pydeps. My project is pretty simple, and relies on two primary modules. To create a dependency graph I simply ran pydeps against those two modules like so:

(macapi) dustin@localhost:~/macapi$ pydeps ~/projectpath/main.py
(macapi) dustin@localhost:~/macapi$ pydeps ~/projectpath/utilities.py

Both commands created a .png file and displayed what modules imported one another. Here is what that looked like:

While using this tool, I realized that crud and utilities imported one another. My app still functioned at that time but I realized that I should refactor the crud function that used a utilities function.

Now, what do all these modules do for my project? Here’s a quick list to explain:

  • database: handles database connection process
  • models: hosts classes and methods related to individual SQL tables
  • crud: handles insert and select statements for the project
  • schemas: handles data validation for the project
  • net_cmds: interacts with network devices
  • utilities: handles scheduled events and miscellaneous requirements
  • main: runs FastAPI

To further break down each module, I also use cherryTree to brainstorm, jot down notes, create lists such as required functions per module, etc. I add, remove, and check off features as I go: