lib/ is intended to be for non-app specific library code that just happens to live in the app for now (usually pending extraction into open source or whatever). - DHH
So here's an example of things that belong in /lib:
- API wrappers
- Utility functions
- Core extensions
- Tasks
- Assets
- Generators
- Custom middleware