Project - Automate common Phoenix tasks so you can start building your idea faster

Project

Why?

Every time I start a new Phoenix project, I find myself doing the same repetitive stuff: swapping esbuild for Bun, adding Oban, configuring Credo, removing DaisyUI components I don’t need, setting up pgvector, etc.

I also have very specific preferences that take forever to do manually on every project, like sorting mix.exs dependencies by name, implementing @PJUllrich’s Unaccented Name Search With Postres, and all the things in @JohnnyCurran’s The Modifications I Make to Every New Phoenix Project.

Igniter.install is great for getting started but isn’t available in many older projects, often has optional steps left out (adding Oban.Telemetry.attach_default_logger() in application.ex when installing Oban), and afaik hasn’t been used yet for removing code from Phoenix (like getting rid of all Topbar.js or DaisyUI code, not just the dependencies).

Project

Project saves you time by skipping the repetitive boilerplate setup and removal code at the start (or middle!) of every Phoenix project. Run custom, composed Igniter tasks at one time, with a single command.

Features

  • Add tasks - Install and configure packages like Bun, Oban, Credo, Pgvector, and more
  • Remove tasks - Clean up unwanted code like DaisyUI, Topbar, theme toggle
  • Gen tasks - Generate boilerplate code and run convenience tasks

Installation

Add project to your list of dependencies in mix.exs:

def deps do
  [
    {:project, "~> 1.0"}
  ]
end

Generate a custom setup task for your project:

mix project.gen.setup

This creates lib/mix/tasks/<your_app_name>.setup.ex which you can edit to control which tasks run and in what order.

Or run the default setup task directly

mix project.setup

Usage

Optional tasks can be added via flags:

mix project.setup --oban-pro --gigalixir --mix-test-watch
mix your_app_name.setup --oban-pro 

Any task can be run individually

Add a package:

mix project.add bun
mix project.add oban,credo,pgvector

Remove code:

mix project.remove daisy_ui
mix project.remove theme_toggle

Generate code:

mix project.gen home_page
mix project.gen app_layout

Available Tasks

Add Tasks

  • bun - Replace esbuild with Bun
  • credo - Add Credo for static analysis
  • dotenv_parser - Add DotenvParser for .env files
  • ex_sync - Add ExSync for auto-recompilation
  • libcluster - Add libcluster for node clustering
  • mix_test_watch - Add mix_test_watch for running tests on file changes (optional)
  • oban - Add Oban for background jobs
  • oban_pro - Add Oban Pro extensions (optional)
  • oban_web - Add Oban Web UI
  • pgvector - Add pgvector for vector similarity search
  • quokka - Add Quokka for code formatting
  • remix_icons - Add Remix Icons
  • tidewave - Add Tidewave MCO
  • uuidv7 - Add UUIDv7 support

Remove Tasks

  • daisy_ui - Remove DaisyUI components
  • live_title_suffix - Remove live title suffix
  • repo_credentials - Remove repo credentials from config
  • theme_toggle - Remove theme toggle functionality
  • topbar - Remove Topbar.js

Gen Tasks

  • app_layout - Generate a clean app layout
  • class_formatter - Generate TailwindCSS class formatter
  • gigalixir - Generate Gigalixir deployment config (optional)
  • gitignore - Generate .gitignore additions
  • graph_db - Generate graph database tables for nodes and edges (optional)
  • home_page - Generate a minimal home page
  • pg_extensions - Generate PostgreSQL extensions migration
  • repo_config - Generate repo configuration
  • schema - Generate schema helpers
  • sort_deps - Sort mix.exs dependencies alphabetically

Customization

After running mix project.gen.setup, edit the tasks/0 function in lib/mix/tasks/<your_app_name>.setup.ex.

  • Reorder tasks
  • Remove tasks you don’t need
  • Add your own custom tasks
  • Use {:optional, :flag_name} placeholders for custom flags

What’s next?

I’m be adding more tasks based on what I find myself needing and which tasks are contributed. Ideally, this becomes a community-led compendium of custom tasks! :heart::heart::heart::front_facing_baby_chick::fire:


Hex: project | Hex
Twitter: https://x.com/random
GitHub:

14 Likes

Looks great, maybe a good candidate would be items related to authentication and user/roles management plus things like 2FA as in most discussions the team opt against having it in the core skeleton generated by framework which makes sense due to different variations possible but that does not mean it is not repetitive in nature in most of cases

Thanks :purple_heart: mix phx.gen.auth mostly handles this for me, but interested in what others think!

Correct but I am not aware of it handling things like access control whether you use RBAC or ABAC plus two factor authentication and those things mostly required in enterprise apps

1 Like

I see how this could be useful if you happen to repeat the same setup over and over again.

Regarding the installation, project should be installed only for the dev environment, right? So this would be {:project, "~> 1.0", only: :dev}. I don’t see why it would be needed in test and prod environments.

you’re right, will update!

i personally don’t even push it to version control. i install it, generate what i need, and remove it :sweat_smile: