How htooaungphyolwin/adonisjs-blog works
Project type and purpose
• This is a full-stack Content Management System (CMS) built on AdonisJS (Node.js framework) with a server-side rendered frontend using the Edge template engine.
• The README describes core features: user authentication, posts, comments, likes, view tracking, and a modern UI built with Tailwind CSS/Flowbite and Vite.
File structure
• Top-level directories:
• app/ — Contains MVC elements: controllers, models, middleware, validators
• config/ — Application configuration (database, auth, bodyparser, sessions…)
• database/ — Migration scripts for SQLite tables
• resources/ — Static assets (css/js) and Edge view templates
• start/ — Bootstrap files: routes, kernel (middleware registration), view config
• public/ — Publicly hosted assets (images, compiled files)
• bin/ — Entry points for console commands, server start, tests
• tests/ — Automated test setup
• Patterns:
• MVC: controllers (handle requests), models (ORM Lucid), views (Edge)
• Middleware pipeline for auth/guest checks
• Database migrations define schema
README for additional insights
• Confirms use of AdonisJS 6, SQLite default, Edge templating, Vite dev server.
• No external microservices; it’s a monolithic server that renders pages and serves an API for client-side interactions.
a. Main components
1. Client Browser
• Sends HTTP requests, runs frontend JS/CSS (Vite-built assets)
2. AdonisJS Server
• HTTP server listening on port 3333
• Routes (start/routes.ts) → Middleware → Controllers
• Controllers invoke Models (Lucid ORM)
• Uses Edge to render HTML or returns JSON for AJAX
3. SQLite Database
• Persists users, posts, comments, likes, view_counts
4. Static Asset Pipeline
• Vite development server or built assets served from public/
5. Optional: Console & Test Runners
• bin/console.ts for CLI commands (e.g., migrations)
• bin/test.ts invokes test suite
b. Relationships & interactions
• Client → HTTP Request → Server Route
• Server Route → Middleware (auth_middleware, etc.) → Controller
• Controller → Model (Lucid) → Database
• Controller → Render Edge View or JSON Response → Client
• Client static asset requests → public/ folder or Vite dev server
c. Architectural patterns & design principles
• MVC separation: clear division of concerns
• Middleware pipeline for cross-cutting concerns (authentication, binding)
• RESTful resource controllers (posts, comments, user_profile)
• Config-driven environment (config/ files, .env)
• Monolithic deployment: single process handles web, API, CLI
d. Key technologies & libraries
• AdonisJS 6 core (HTTP server, Lucid ORM, Edge)
• SQLite (via Lucid)
• Tailwind CSS, Flowbite for styling
• Vite for asset bundling
Detailed breakdown to capture essential elements
• Routes (start/routes.ts)
• Middleware Layer
• Controllers (list key controllers: auth, posts, comments, profile)
• Validators
• Exception Handler
• Lucid ORM
• “bin/console” and “tests” as side utilities