Skip to content

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/core in package.json and an adonisrc.ts
  • start/routes.ts and start/kernel.ts
  • app/controllers/, app/models/ and app/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

  1. start/routes.ts
  2. start/kernel.ts, for which middleware applies globally
  3. The controller action and the models it uses

How a request moves through the code

  1. 1Server middleware from start/kernel.ts runs.
  2. 2The router matches the route; router and named middleware run (for example auth).
  3. 3The controller action validates input with a VineJS validator.
  4. 4It calls Lucid models or services, resolved through the container.
  5. 5It 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 adonisrc before applying docs.
  • Controllers are often lazy-loaded with import functions in routes, so search by file path rather than by import.