Skip to content
/ farm Public

How I tend to setup bounded contexts in elixir/phoenix.

Notifications You must be signed in to change notification settings

kerryjj/farm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Farm

Shows quickly how I tend to setup bounded contexts in elixir/phoenix with complex data access. Once the queries and database access become more than just CRUD I create a repo dedicated to the database access for this bounded context.

There are a couple of principles that I currently keep in mind and these drive me to a structure like this. These principles are:

  • Changesets and modules that contain DB schema (model) definitions should not contain any business logic
  • Validation of user inputs should happen as close to the edge as possible.
    • That often means user input validation is done in a controller or plug and not left for the changeset to sort out.

To get to the point that the test are run:

  • Install and run a local test version of postgres
    • docker run -d --name my_postgres -v my_dbdata:/var/lib/postgresql/data -p 54320:5432 postgres:11
  • Create the farm_test database
    • mix ecto.create
    • mix ecto.migrate
  • Run the tests
    • mix test

I'd definitely like feedback on this as a general approach.

If you have any comments/feedback please leave them with this repo. Or submit a PR with your suggestions as code :)

About

How I tend to setup bounded contexts in elixir/phoenix.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages