DIY AI Part 4: Setting up your file system for seamless coding
By Ed Malaker
If you have been following along with our guide, you now have Visual Studio Code set up with Python and a project file with a virtual environment stored inside. You will also want to work from within your virtual environment as you work on the project. If any of this sounds new to you, it’s probably a good idea to go back and start at the beginning. For the rest of us, this should be the last part before we start doing some real coding. This time, we’ll be setting up the file system, which will be really easy but is the backbone of the entire project, helping us keep everything organized and accessible no matter how large it grows.
Why this folder structure?
As mentioned, a well-designed folder structure will help you keep everything organized, making it easy to find what you need. It will also allow your project to grow without becoming messy or confusing.
The organized files will also facilitate teamwork and align with industry standards, ensuring your project is easy to maintain or integrate with other systems.
The recommended folder structure
The following is a list of folders that we recommend adding to your project file, along with the virtual environment folder you should already have. To create a folder, right-click on the side and select “ New Folder.” While the folders will be empty right now, they will quickly fill up as you develop your project.
project_root/
your_virtual_environment/
src/
tests/
data/
logs/
docs/
requirements.txt
README.md
What goes in each folder?
src/
The src/ folder will hold all of the source files for your project. These will be the scripts that perform the main tasks of your project, such as file handling, searching, or analyzing data.
Top modern programming languages driving the future of development
tests/
The tests folder will hold any scripts you create to test the scripts in your src/ folder. The files in this folder will help ensure that your project is performing as it should and is free of glitches and bugs. Think of this folder as the debugger.
data/
The data folder is where you will store any data that your program requires. For instance, if you have a script that needs to check a spreadsheet for information. You will keep that spreadsheet in the data file. You will also store outputs from your scripts so you can compare or review them later.
logs/
The logs folder will contain any logs generated by your program, primarily error logs that will be essential for debugging your code.
docs/
The docs file will hold documentation related to your program, including user guides or technical references.
requirements.txt
The requirements.txt file is not a folder, but it’s a good idea to include it in your directory setup so you can keep it up to date. This file lists all of the Python libraries that you are using, which can make it easier for another team member to set up the same environment on their machine. It’s also helpful if you like to code on multiple computers.
README.md
A .md file is a Markdown Documentation file that formats text using the Markdown language. We can use it to create a file that tells people about your program and provides directions on how to use it. It can be fun to write to see how it changes over time, or you can leave it out for now.
This folder structure is a solid foundation for any Python project, whether you’re working solo or collaborating with a team. We’ll use it for this project moving forward.
Follow GeekSided to stay up to date on creating an AI from scratch.