Search code examples
angular8angular9angular10angular11

How to create folder structure for modules in angular10


I have two modules like education and transport. I want to create modules and components for these. How to create a perfect folder structure for these. If anyone knows please help.

education
->school
   --> 1std component 
   --> 2std component
   --> 3std component
->college
   --> arts component
   --> engg component 
   --> diploma component 


transport
->cycle
   --> small component 
   --> medium component 
   --> large component 
->bike
   --> pulsar component 
   --> honda component 
   --> hundai component 

Demo: https://stackblitz.com/edit/angular-ivy-atpxot?file=src%2Fapp%2Fapp.module.ts


Solution

  • May be following folder structure would be useful for you!

    -app
      
    -shared
      -services
      -pipes
      -components
      -models
    
    -modules
      -education
        -components
            -school
            -college
        -models
            -education.model.ts
        -services
            -education-service.ts
    
        -education.component.ts // this component should act like a container
        -education.component.html
        -education.component.module.ts        
        -education.component.route.ts
    
      -transport
        -components
            -cycle
            -bike
        -models
            transport.model.ts
        -services
            transport.service.ts
            
        -transport.component.ts // this component should act like a container
        -transport.component.html
        -transport.component.module.ts        
        -transport.component.route.ts
    
    -app.component.ts
    -app.component.html
    -app.module.ts
    -app-routing.module.ts
    

    Above folder structure gives a kind of micro-service architecture as well where each module having its own services/dependencies.