Ai Writer - Developer Documentation

This document provides a technical overview of the Ai Writer architecture for developers wishing to extend or modify the platform.

1. Architecture Overview

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.

Directory Structure

/
├── .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.

2. Core Components

Routing (src/Core/Router.php)

$router->get('/story/{slug}', 'StoryController', 'show');

Database (src/Core/Database.php)

Models (src/Core/Model.php)

Views (src/Core/View.php)

return $this->view('themes.default.home', ['data' => $data], 'public'); 
      // Renders views/themes/default/home.php inside views/layouts/public.php

3. The Installer System

The installer is a transient system designed to run once.

4. Key Security Features

5. How to Extend

Adding a New Feature

  1. Database: Add new tables to a migration file or update schema.sql for new installs.
  2. Model: Create a class in src/Models/ extending DeptoBlog\Core\Model.
  3. Controller: Create a class in src/Controllers/.
  4. Route: Register the route in src/routes.php.
  5. View: Create the template in views/.

6. Debugging