This document provides a technical overview of the Ai Writer architecture for developers wishing to extend or modify the platform.
Ai Writer follows a custom MVC (Model-View-Controller) architecture built with vanilla PHP. It does not rely on heavy frameworks like Laravel or Symfony, making it lightweight and fast.
/
├── .env # Environment configuration (Auto-generated)
├── public/ # Web root
│ └── index.php # Entry point
├── src/
│ ├── Controllers/ # Logic layer
│ ├── Models/ # Data layer (extends Core\Model)
│ ├── Core/ # Framework core (Router, Database, View, etc.)
│ └── routes.php # Route definitions
├── views/ # UI Templates (PHP files)
│ ├── layouts/ # Master layouts
│ ├── admin/ # Admin dashboard views
│ ├── public/ # Frontend views
│ └── installer/ # Installer views
└── schema.sql # Database schema
Note on PHP Namespace: The class files utilize the PHP namespace
DeptoBlog for PSR-4 autoloading registry compatibility. When writing new classes,
place them under the DeptoBlog namespace to align with the core MVC loader.
src/Core/Router.php)src/routes.php.GET, POST./story/{id}).
$router->get('/story/{slug}', 'StoryController', 'show');
src/Core/Database.php).env.Database::getInstance().
src/Core/Model.php)all(), find($id),
where($col, $val), create($data),
update($id, $data), delete($id).
$this->db->prepare().
src/Core/View.php)views/.return $this->view('themes.default.home', ['data' => $data], 'public');
// Renders views/themes/default/home.php inside views/layouts/public.php
The installer is a transient system designed to run once.
public/index.php checks for the
existence of .env.
/install (handled by
InstallerController).
/install and loads the main application.
src/Controllers/InstallerController.php.
.env.
htmlspecialchars() where appropriate).
password_hash() with
PASSWORD_DEFAULT (modern BCRYPT/Argon2Id).
$_SESSION['role'] for access control (e.g.,
AdminController, AuthorController).
schema.sql for new installs.
src/Models/ extending DeptoBlog\Core\Model.
src/Controllers/.
src/routes.php.
views/.
APP_DEBUG=true in .env to see errors.