Just wondering if I use glass mapper or any DI framwork then will I need to implement in each project separetly? otherwise if I create a separate project for DI or Glassmapper and add the reference in each habitat project then i guess it will break the habitat rule which says keep the module separate.
You can put it to the Foundation layer. Any project in any layer can have references to the Foundation layer. Also, a Foundation project can have references to another Foundation project, but you need to follow this rule:
Unlike the Feature layer, there is no strict convention on dependencies between modules in the foundation layer. This means that one Foundation layer module can depend on another Foundation layer module in the solution – as long as they rely on the basic principles on component architecture such as the Acyclic Dependencies Principle and the Stable Abstractions Principle:
Source: Helix principles
Do not forget that Habitat is just an example of how Helix principles should be applied.