Python · Boilerplate Automation
Create a Whole Project Folder Structure from a Python Dictionary
Define your folders and files as a nested dictionary in folders.py, run it, and the whole project skeleton appears on disk - safe to re-run because nothing is overwritten.
Pythonos.makedirsClean ArchitectureDDD
Abstract
The problem
Starting a project means manually creating dozens of nested folders and __init__.py files, which leads to inconsistent naming across projects.
The solution
A recursive engine that translates a high-level dictionary blueprint into a real directory tree on disk.
The result
Instant, error-free initialisation that keeps every new app on the same architectural standard.
Input & Output
Input
- structure dictionary and project_root name inside folders.py
Output
- A new project folder with the full hierarchy of directories and empty files
Optional output
- Automatic __init__.py package markers for immediate importability
System Diagram
Blueprint dict
Dicts = folders, lists = files
create_structure()
Recursive, depth-first
Path joining
Windows / Linux / macOS
Project on disk
exist_ok=True · idempotent
How It Works
Dictionary-defined
Nested dicts are sub-directories, lists are files, empty strings are root files.
Recursive creation
Depth-first traversal with OS-independent path handling.
Idempotent
exist_ok=True means re-runs never error or overwrite.
Clean Architecture template
src/core, src/domain, src/data and src/ui are pre-configured.
Configuration
| Option | Purpose |
|---|---|
project_root | Name of the project folder to create. |
structure | The blueprint dictionary – edit it to change the layout. |
How to Run
structure = {"api": ["routes.py", "models.py"], "docs": {"manual": ["install.md"]}, "config.yaml": ""}python folders.pyImpact & Benefits
Screenshots
Frequently Asked Questions
How do I create nested folders in Python from a dictionary?
A recursive create_structure() function walks the dict: nested dicts become folders, lists become files, empty strings become root files.
Will running it twice overwrite my files?
No. It uses exist_ok=True, so existing folders are left alone.
Does it support Clean Architecture?
The default blueprint includes src/core, src/domain, src/data and src/ui following Clean Architecture and DDD.
Related
Generate a Clean Folder Tree of Any Project with Python
Generates a filtered, tree-style map of any codebase for READMEs, onboarding and AI context.
Read documentation