38 lines
1.7 KiB
Markdown
38 lines
1.7 KiB
Markdown
# Backend Architecture
|
|
|
|
The current backend is based on AdonisJS v6. Use the official AdonisJS folder structure as the default baseline:
|
|
|
|
https://v6-docs.adonisjs.com/guides/getting-started/folder-structure
|
|
|
|
## Default Folders
|
|
|
|
| Folder | Purpose |
|
|
| ----------- | -------------------------------------------------------------------------------------------- |
|
|
| `app/` | Application code: controllers, services, middleware, policies, validators, and domain logic. |
|
|
| `start/` | Boot lifecycle files such as routes, kernel setup, env loading, and event registration. |
|
|
| `config/` | Runtime configuration for AdonisJS and installed packages. |
|
|
| `database/` | Migrations and seeders. |
|
|
| `bin/` | Entrypoints for server, console, and tests. |
|
|
| `public/` | Static files and generated public assets. |
|
|
| `tests/` | Backend tests. |
|
|
|
|
## Basic Flow
|
|
|
|
```txt
|
|
start/routes.ts
|
|
-> controller
|
|
-> validator / policy
|
|
-> service
|
|
-> model / database / external service
|
|
```
|
|
|
|
Controllers should handle HTTP concerns. Services should hold business logic. Validators should own request validation. Policies and abilities should own authorization.
|
|
|
|
## Rules
|
|
|
|
- Follow AdonisJS conventions first.
|
|
- Keep HTTP logic out of services.
|
|
- Keep business logic out of controllers.
|
|
- Validate request input before calling services.
|
|
- Use policies or abilities for protected operations.
|