How to structure an Elm project?
The answer to this question can be found in the Beginning Elm book. This question will therefore be removed at some time in the future.
Do not overuse: Files are allowed to get quite big without needing to split them.
Question
How should I structure my Elm project?
Answer
Use the following file structure:
Main.elm - Contains the main code
Data.elm - Contains utility functions for types (like constants)
Data/.. - Contains types. Group them logically, for example
User
andUserForm
intoData/User.elm
.
View.elm - Contains utility functions for views (like view specific constants and very general function.)
View/.. - Contains different Views. Sometimes a type has different views. A login page might have a special view for a wrong login.
Page.elm - Contains utility functions for pages. For page-transitions its handy to store the different models in here.
Page/.. - Contains a Model/View/Update for every page.
.. - in the same style you can add your project specific folders like a separate folder for validation.
Further reading
📄Article: NoRedInk Style Guide
👥Thread: Code structure/architecture
📄Article: Tour of an Open-Source Elm SPA by Richard Feldman
🎥Video: The life of a file by Evan Czaplicki
Last updated