My Folder Structure for Backend Projects
I've organized my backend projects using a folder structure that I've found to be the most effective so far. Here's how it looks:
.project-root/
├── .env
├── package.json
├── tsconfig.json
├── src/
│ ├── app.ts
│ ├── controllers/
│ │ └── Controller.ts
│ ├── domain/
│ │ └── .ts
│ ├── middlewares/
│ │ └── .ts
│ ├── repositories/
│ │ └── Repository.ts
│ ├── routers/
│ │ └── Router.ts
│ ├── services/
│ │ ├── jwtService.ts
│ │ └── passwordService.ts
│ ├── databases/
│ │ ├── db.ts
│ │ └── migrations/
│ │ └── .ts
│ ├── types/
│ │ └── index.d.ts
│ └── usecases/
│ └── Usecase.ts
│
└── docs/
└── README.md
Why This Structure?
1. Because it has great separation of concerns.
2. Because it makes dependency injection easier.
3. Because it supports modularity and makes extending or modifying the application straightforward.
4. Because it improves readability and organization, helping new developers quickly understand the project.
I'd love to hear your thoughts on this structure. How does it align with your practices? Any suggestions or improvements based on separation of concerns, dependency injection, or other architectural principles?