How to understand a AdonisJS codebase
AdonisJS is a batteries-included MVC framework for Node. Routes are declared in one file, controllers handle requests, Lucid models talk to the database, and services are resolved through an IoC container. Version 6 is ESM and TypeScript-first.
How to tell it's AdonisJS
@adonisjs/coreinpackage.jsonand anadonisrc.tsstart/routes.tsandstart/kernel.tsapp/controllers/,app/models/andapp/middleware/
Where things usually live
- start/routes.ts
- Every route, groups, prefixes and middleware.
- start/kernel.ts
- Server, router and named middleware registration.
- app/controllers/
- Controller classes with action methods.
- app/models/
- Lucid ORM models, relationships and hooks.
- app/validators/
- VineJS validation schemas.
- config/
- App, database, auth, session configuration.
- database/migrations/
- Schema migrations.
Conventions, not rules. Real projects rename and move things, so confirm against the repository.
Where to start reading
start/routes.tsstart/kernel.ts, for which middleware applies globally- The controller action and the models it uses
How a request moves through the code
- Server middleware from
start/kernel.tsruns. - The router matches the route; router and named middleware run (for example
auth). - The controller action validates input with a VineJS validator.
- It calls Lucid models or services, resolved through the container.
- It returns a response, a redirect or a rendered view.
Questions to ask about the repository
- List the route groups and the middleware attached to each.
- Which models have hooks, and what do they do?
- How is authentication configured: sessions, tokens or both?
What trips people up
- AdonisJS 5 and 6 differ in module system and folder names; check
adonisrcbefore applying docs. - Controllers are often lazy-loaded with import functions in routes, so search by file path rather than by import.