Learn ADONISJS with Real Code Examples
Updated Nov 27, 2025
Explain
AdonisJS provides a structured MVC architecture with built-in support for routing, ORM, validation, authentication, and more.
It emphasizes convention over configuration, offering a cohesive and batteries-included ecosystem.
Supports synchronous and asynchronous programming via modern JavaScript/TypeScript.
Integrates easily with relational databases, caching, queues, and WebSockets.
Designed for both small applications and scalable enterprise-grade projects.
Core Features
Routing and controllers
Lucid ORM for relational databases
Middleware and service providers
Validation and exception handling
Real-time WebSocket channels
Basic Concepts Overview
Controller - handles HTTP request logic
Model - interacts with database via Lucid ORM
View - renders templates (optional for APIs)
Middleware - pre/post-processing for requests
Route - maps HTTP requests to controllers
Project Structure
app/ - controllers, models, middleware
database/ - migrations, seeds
start/ - routes and kernel setup
resources/ - views and templates
config/ - framework and database configuration
Building Workflow
Define routes in `start/routes.ts`
Create controllers and define actions
Define models and migrations using Lucid ORM
Add middleware for authentication, logging, etc.
Start server and test API or web endpoints
Difficulty Use Cases
Beginner: basic REST API
Intermediate: CRUD app with authentication
Advanced: real-time app with WebSockets
Expert: full-stack enterprise application
Architect: multi-service, scalable backend
Comparisons
AdonisJS vs Express -> AdonisJS is opinionated and batteries-included; Express is minimalistic
AdonisJS vs NestJS -> Both TypeScript-friendly; NestJS uses decorators and dependency injection heavily
AdonisJS vs Koa -> Koa is middleware-centric and lightweight; AdonisJS is full-featured
AdonisJS vs Sails -> Sails is MVC and ORM-heavy; AdonisJS is modern and TypeScript-native
AdonisJS vs LoopBack -> LoopBack focuses on APIs; AdonisJS provides full-stack capabilities
Versioning Timeline
2015 - AdonisJS initial release
2016 - v2 with improved ORM and authentication
2018 - v4 with TypeScript support
2020 - v5 modern rewrite with TypeScript-first approach
2025 - Latest v5.x release with updated ecosystem and WebSocket enhancements
Glossary
Controller - handles request logic
Model - ORM representation of database table
Route - maps HTTP requests to controllers
Middleware - pre/post-processing requests
Lucid - ORM for database interactions