Project Layout
This section will cover the suggested layout of your project when using the Sodacore framework.
For context, it really doesn't matter, even when using Autowiring (which we recommend by default), the autowire will scan all folders and files within your basePath
(or current working directory if not set) for classes that have decorators, so you can put them anywhere.
/project-root
/src
/commands # Discord plugin.
MyCommand.ts
/controllers # HTTP, WebSocket, etc...
HelloController.ts
/events # Discord plugin.
MyEvent.ts
/middleware # HTTP middleware.
MyMiddleware.ts
/providers # Utilities that require DI.
MyProvider.ts
/scripts # CLI scripts.
MyScript.ts
/services # Custom services.
MyService.ts
/workers # Workers for CPU intensive tasks.
MyWorker.ts
main.ts
/prisma # If you use Prisma.
/translations # If you use i18n.
.env
bun.lock
package.json
tsconfig.json
This keeps the structure simple, if you intend to create a more complex project, we suggest breaking down your folders into "modules" where each one contains it's own set of folders (like the above) that have feature-related logic.
For example:
/project-root
/src
/auth
/controllers
AuthController.ts
/providers
AuthProvider.ts
/services
AuthService.ts
/user
/controllers
UserController.ts
/providers
UserProvider.ts
/services
UserService.ts
main.ts
Otherwise follow whatever your heart desires, as noted, the autowire tool won't care, the only difference is when working with plugins, which requires manual registration of controllers, middleware, etc... but that is documented in the respective plugin documentation.