How arpitthool/blogger-app works
Purpose and Runtime
A server-rendered Blogger application built with TypeScript, AdonisJS, Edge templates, and PostgreSQL. Guests browse blogs and register; authenticated users create/delete their blogs and like/dislike posts. The Node/Adonis HTTP runtime starts at server.ts, with CLI lifecycle commands exposed through ace and commands/index.ts.
HTTP Composition and Routing
Routes are the application control-plane entry point in start/routes.ts; middleware registration/order is defined in start/kernel.ts. Requests flow through Adonis middleware, controllers, Lucid ORM models, then render Edge views or redirect. Global error translation is centralized in app/Exceptions/Handler.ts.
Authentication and Access Boundaries
Authentication is configured as session/cookie-based Adonis auth in config/auth.ts and config/session.ts. app/Middleware/Auth.ts gates logged-in actions, app/Middleware/Guest.ts protects guest-only pages, and app/Middleware/SilentAuth.ts likely makes optional identity available for public pages. Account/session endpoints belong to app/Controllers/Http/AuthController.ts; user persistence is app/Models/User.ts.
Blog Domain and Ownership
Blog CRUD/read behavior is concentrated in app/Controllers/Http/BlogsController.ts, backed by app/Models/Blog.ts. The principal authorization boundary is ownership: authenticated users can create and delete only their own blog records. Public index/detail and user-specific views are rendered from resources/views/blogs/index.edge, resources/views/blogs/view.edge, and resources/views/blogs/userIndex.edge.
Social Interactions
Likes and comments are independent domain flows attached to blogs and users. Their request handlers are app/Controllers/Http/LikesController.ts and app/Controllers/Http/CommentsController.ts; persistence models are app/Models/Like.ts and app/Models/Comment.ts. Comment author-name support is represented in database/migrations/1727312708346_add_user_name_to_comments.ts.
Persistence Lifecycle
PostgreSQL connectivity is configured in config/database.ts from validated environment definitions in env.ts. Schema evolution establishes users, blogs, likes, and comments through database/migrations/1699475376434_users.ts, database/migrations/1699505616366_blogs.ts, and database/migrations/1726342752206_comments.ts. Optional initial data enters through database/seeders/MainSeeder/Index.ts.
Presentation and Deployment Boundaries
Edge templates form the UI boundary, sharing layout/navigation via resources/views/layouts/app.edge and resources/views/layouts/partials/_navbar.edge; auth pages reside under resources/views/auth. Static files and local drive behavior are configured by config/static.ts and config/drive.ts. A Dockerfile supports containerization; production uses Adonis’s compiled build and Node server runtime.
Main entry points: routes.ts Routes · Blog.ts Blog social models · Auth.ts Access middleware · AuthController.ts Account sessions
Components 20
Runtime & CLI
- Adonis HTTP server
server.ts - CLI lifecycle commands
commands/index.ts
HTTP & Access
- Routes
start/routes.ts - Middleware pipeline · Defines middleware registration and order.
start/kernel.ts - Session authentication
config/auth.ts - Access middleware
app/Middleware/Auth.ts - Account sessions
app/Controllers/Http/AuthController.ts - Error translation
app/Exceptions/Handler.ts
Blog Domain
- Blog read and CRUD · Enforces creator ownership for blog deletion.
app/Controllers/Http/BlogsController.ts - Like interactions
app/Controllers/Http/LikesController.ts - Comment interactions
app/Controllers/Http/CommentsController.ts - Blog social models · Blogs, likes, and comments link content to users.
app/Models/Blog.ts - User model
app/Models/User.ts
Presentation
- Blog Edge views · Index, detail, and user-specific blog pages.
resources/views/blogs/index.edge - Shared layout and navigation
resources/views/layouts/app.edge - Authentication pages
resources/views/auth
Data & Schema
- PostgreSQL connection · Connection settings derive from validated environment values.
config/database.ts - PostgreSQL
- Schema migrations · Creates user, blog, like, and comment schema.
database/migrations/1699475376434_users.ts - Initial data seeder
database/seeders/MainSeeder/Index.ts
Connections 24
- Adonis HTTP server → Routes: serves requests
- Adonis HTTP server → Middleware pipeline: runs pipeline
- CLI lifecycle commands → Schema migrations: runs lifecycle tasks
- Routes → Account sessions: account endpoints
- Routes → Blog read and CRUD: blog endpoints
- Routes → Like interactions: like endpoints
- Routes → Comment interactions: comment endpoints
- Middleware pipeline → Access middleware: applies access rules
- Session authentication → Access middleware: configures identity
- Access middleware → Account sessions: guards session actions
- Access middleware → Blog read and CRUD: guards ownership actions
- Blog read and CRUD → Blog social models: reads and mutates blogs
- Like interactions → Blog social models: persists reactions
- Comment interactions → Blog social models: persists comments
- Account sessions → User model: manages accounts
- Blog social models → User model: belongs to users
- Blog read and CRUD → Blog Edge views: renders or redirects
- Account sessions → Authentication pages: renders auth pages
- Blog Edge views → Shared layout and navigation: uses shared shell
- PostgreSQL connection → PostgreSQL: connects to
- Blog social models → PostgreSQL: queries via Lucid
- Schema migrations → PostgreSQL: evolves schema
- Initial data seeder → PostgreSQL: loads initial data
- Middleware pipeline → Error translation: forwards failures