Looking for critique on my directory layout

My directory structure here has really gotten away from me. I have a hard time finding LiveView templates and business logic.

I’ve been doing Rails most recently, so I really miss having /models and /views.

One Phoenix pattern (I think) I’ve been doing consistently is user.ex for the “model” data definition and ecto if appropriate. And then users.ex for aggregate and data lookup functions.

Please hit me with your most intense critique! Am I doing things “The Phoenix Way”? Here are my directories only, then another listing that includes files.

Interesting food for thought. This excellent video covers several different codebase organization styles along with all their tradeoffs: https://www.youtube.com/watch?v=dabeidyv5dg I’m watching this a second time, thinking about it.

For context: this app works with domains, urls, and sitemaps. So those are business domain concepts, not architectural details:

lib
├── index_flow
│   ├── analytics
│   ├── billing
│   ├── customers
│   ├── domains
│   ├── index_now
│   ├── indexing
│   ├── pow
│   ├── sitemap
│   ├── sitemaps
│   ├── users
│   ├── utils
│   ├── webhooks
│   └── workers
└── index_flow_web
    ├── components
    │   ├── layouts
    │   └── shared
    ├── controllers
    │   ├── email_confirmation_html
    │   ├── page_html
    │   ├── pow
    │   │   ├── registration_html
    │   │   └── session_html
    │   └── pow_reset_password
    │       └── reset_password_html
    ├── live
    │   └── dashboard_modals
    ├── plugs
    ├── pow
    └── views
        └── pow_email_confirmation

33 directories

And now with files:

lib
├── index_flow
│   ├── analytics
│   │   ├── daily_stats.ex
│   │   ├── sitemap_stats.ex
│   │   └── usage_tracking.ex
│   ├── analytics.ex
│   ├── application.ex
│   ├── billing
│   │   ├── plan.ex
│   │   ├── plans.ex
│   │   ├── stripe_client_behaviour.ex
│   │   ├── stripe_client.ex
│   │   ├── stripe_webhook_client.ex
│   │   └── subscription.ex
│   ├── billing.ex
│   ├── config.ex
│   ├── customers
│   │   ├── customer.ex
│   │   ├── supervisor.ex
│   │   └── worker.ex
│   ├── customers.ex
│   ├── domain_interactor.ex
│   ├── domains
│   │   └── domain.ex
│   ├── domains.ex
│   ├── env.ex
│   ├── error_logger.ex
│   ├── frequency_tracker.ex
│   ├── http_client.ex
│   ├── index_now
│   │   ├── client.ex
│   │   ├── submission_coordinator.ex
│   │   └── submission.ex
│   ├── index_now.ex
│   ├── indexing
│   │   ├── tracked_url.ex
│   │   └── url_tracker.ex
│   ├── indexing.ex
│   ├── mailer.ex
│   ├── notifications.ex
│   ├── pow
│   │   └── store.ex
│   ├── rate_limiter.ex
│   ├── release.ex
│   ├── repo.ex
│   ├── sitemap
│   │   ├── fetcher.ex
│   │   ├── parser.ex
│   │   └── robots_discovery.ex
│   ├── sitemap_interactor.ex
│   ├── sitemaps
│   │   └── sitemap.ex
│   ├── sitemaps.ex
│   ├── topic.ex
│   ├── usage_tracker.ex
│   ├── users
│   │   └── user.ex
│   ├── users.ex
│   ├── utils
│   │   ├── changeset.ex
│   │   ├── css.ex
│   │   ├── date_time.ex
│   │   ├── formatting.ex
│   │   ├── live_view.ex
│   │   ├── params.ex
│   │   ├── url.ex
│   │   └── validation.ex
│   ├── webhooks
│   │   └── webhook.ex
│   ├── webhooks.ex
│   └── workers
│       ├── customer_check_worker.ex
│       ├── daily_aggregator.ex
│       ├── domain_discovery_worker.ex
│       ├── domain_full_process_worker.ex
│       ├── job_scheduler.ex
│       ├── sitemap_processor.ex
│       ├── submission_worker.ex
│       └── worker_helpers.ex
├── index_flow_web
│   ├── components
│   │   ├── core_components.ex
│   │   ├── layouts
│   │   │   ├── app.html.heex
│   │   │   └── root.html.heex
│   │   ├── layouts.ex
│   │   └── shared
│   │       └── spinner.ex
│   ├── controllers
│   │   ├── email_confirmation_controller.ex
│   │   ├── email_confirmation_html
│   │   ├── error_html.ex
│   │   ├── error_json.ex
│   │   ├── fallback_controller.ex
│   │   ├── page_controller.ex
│   │   ├── page_html
│   │   │   └── home.html.heex
│   │   ├── page_html.ex
│   │   ├── pow
│   │   │   ├── controller_callbacks.ex
│   │   │   ├── registration_html
│   │   │   │   ├── edit.html.heex
│   │   │   │   └── new.html.heex
│   │   │   ├── registration_html.ex
│   │   │   ├── session_html
│   │   │   │   └── new.html.heex
│   │   │   └── session_html.ex
│   │   ├── pow_reset_password
│   │   │   ├── reset_password_html
│   │   │   │   ├── edit.html.heex
│   │   │   │   └── new.html.heex
│   │   │   └── reset_password_html.ex
│   │   └── stripe_webhook_controller.ex
│   ├── endpoint.ex
│   ├── gettext.ex
│   ├── live
│   │   ├── auth.ex
│   │   ├── billing_live.ex
│   │   ├── charts_live.ex
│   │   ├── customer_auth.ex
│   │   ├── dashboard_event_handlers.ex
│   │   ├── dashboard_helpers.ex
│   │   ├── dashboard_live.ex
│   │   ├── dashboard_live.html.heex
│   │   ├── dashboard_loader.ex
│   │   ├── dashboard_modals
│   │   │   ├── add_domain_modal.html.heex
│   │   │   ├── delete_domain_modal.html.heex
│   │   │   ├── delete_sitemap_modal.html.heex
│   │   │   └── indexnow_setup_modal.html.heex
│   │   ├── dashboard_modals.ex
│   │   ├── modal_helpers.ex
│   │   ├── urls_live.ex
│   │   └── usage_chart_component.ex
│   ├── plugs
│   │   ├── assign_current_user.ex
│   │   ├── capture_raw_body.ex
│   │   ├── plan_enforcement.ex
│   │   ├── rate_limiter.ex
│   │   ├── require_admin.ex
│   │   ├── require_auth.ex
│   │   └── webhook_parser.ex
│   ├── pow
│   │   ├── mailer.ex
│   │   └── routes.ex
│   ├── router.ex
│   ├── telemetry.ex
│   └── views
│       └── pow_email_confirmation
├── index_flow_web.ex
└── index_flow.ex

33 directories, 119 files

my exp: I started to use Emacs as a text editor, and really works. Reality: you have to configure it to look like VSCode. Now i am using VSCode. I say that cause my mind started thinking: “where the heck is that folder/file”. Short answer: I only use VSCode cause i can visually see the files/folders.
Ideal/Optimal: We could worry about where the files/folders are located? I think Yes, but my main answer to that is: The more you have practice with your own folder enviroment the better. It mighty get times where you will not fit any other person folder structure.
Thinking question: What is the optimal file structure and why?

1 Like