π¦Directory structure
If you had run the getting started instructions from the previous page, you would see the following directory structure for your project:
.
βββ .formatter.exs
βββ .gitignore
βββ README.md
βββ _build
βββ assets
βΒ Β βββ css
βΒ Β βββ js
βΒ Β βββ tailwind.config.js
βΒ Β βββ vendor
βββ config
βΒ Β βββ config.exs
βΒ Β βββ dev.exs
βΒ Β βββ prod.exs
βΒ Β βββ runtime.exs
βΒ Β βββ test.exs
βββ lib
βΒ Β βββ practical_elixir_demo
βΒ Β βββ practical_elixir_demo.ex
βΒ Β βββ practical_elixir_demo_web
βΒ Β βββ practical_elixir_demo_web.ex
βββ mix.exs
βββ mix.lock
βββ practical_elixir_demo_dev.db
βββ practical_elixir_demo_dev.db-shm
βββ practical_elixir_demo_dev.db-wal
βββ priv
βΒ Β βββ gettext
βΒ Β βββ repo
βΒ Β βββ static
βββ test
βββ practical_elixir_demo_web
βββ support
βββ test_helper.exsPhoenix builds on top of the original folder structure that was discussed under the Mix section: Project structure. For more information about Phoenix's directory structure, refer to the official guide.
_build: contains the compilation artifactsassets: stores front-end assets like JavaScript and CSS; static assets like files go topriv/staticconfig: common directory used to store project configurations (more information about order of config reading below)deps: contains all Mix dependencies listed undermix.exsunderdeps/0lib: umbrella project for main application source code wherelib/practical_elixir_demoholds the back-end logic (model) whilelib/practical_elixir_demo_webholds the front-end logic (view and controller)priv: all resources that are necessary in production but not a part of source code like database scripts, static resources, etc.test: contains unit tests for application, similar structure aslib
The specific structure of each folder in lib/ will be discussed when we actually modify those files.
The file that end with *.db-* are the SQLite3 files that maintain the database.
Config order
There are several configuration files that are used in Phoenix (or any Mix project for that matter) and in their read order:
config.exs: base configurations declared for the project, these are read during compile timedev.exs/prod.exs/test.exs: environment specific configurations that run only when the project is run in a given environment (during compile time as well)runtime.exs: configurations that are run during runtime
runtime.exs are the preferred method for loading environment variables from environment files like .env while config.exs are preferred for environment variables that may not be secrets and are readily accessible during compile time.
For more information about configuration files in Elixir, please refer to the official Elixir documentation for the Config module.
Last updated