Skip to content

Latest commit

ย 

History

59 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Write AI

The Next-Generation AI-Powered Content Management & Blogging Platform

Elevate your content creation with an intelligent platform that generates SEO-optimized articles, manages your publications, and fosters reader engagement automatically using the power of Google Gemini AI.

Laravel PHP TailwindCSS JavaScript MySQL Gemini Vite


๐Ÿ“– Overview

Write AI is a highly scalable, robust content management system (CMS) and blogging platform designed for modern creators, authors, and publishers.

Creating high-quality, SEO-optimized blog posts from scratch is time-consuming and often causes writer's block. Write AI solves this by integrating Artificial Intelligence deeply into the drafting process. By simply providing a topic prompt, the platform's AI controller acts as an expert SEO specialist, generating a complete, richly-formatted articleโ€”including a catchy title, meta excerpt, HTML content, and relevant tagsโ€”in seconds. The platform also offers robust social engagement features, allowing readers to interact with authors through comments, favorites, bookmarks, and a comprehensive follow system.


โœจ Features

๐Ÿค– AI Features

  • AI Content Generator: Utilizes Google Gemini 2.5 Flash to automatically draft complete blog posts based on a user-provided prompt.
  • SEO Optimization: AI automatically generates meta excerpts, tags, and SEO-friendly titles alongside the content.
  • Structured JSON Responses: Strict prompt engineering ensures the AI returns clean JSON that perfectly maps to the database structure.

๐Ÿ‘ฅ User & Identity Management

  • Advanced Authentication: Built using Laravel Fortify with support for standard login, Two-Factor Authentication (2FA), and modern Passkeys.
  • Roles & Permissions: Secure Role-Based Access Control (RBAC). Differentiates between standard users, authors, and administrators.
  • Profile Management: Custom user profiles with tracking of account status (Active, Inactive, Suspended) and last activity.

๐Ÿ“ Content Management (CMS)

  • Rich Post Creation: Create articles with cover images, categories, and tags.
  • Post Workflows: Manage articles through multiple states (Draft, Published, Archived).
  • Soft Deletes: Accidentally deleted an article? Safely recover it from the trash or permanently force delete it from the dashboard.
  • View Tracking: Asynchronous event-driven view counters to track article popularity.

๐Ÿ’ฌ Social & Engagement Features

  • Follow System: Users can follow and unfollow their favorite authors to curate their reading experience.
  • Favorites (Likes): Readers can "like" their favorite articles.
  • Bookmarks: Readers can save specific articles to their private reading list.
  • Nested Comments: Interactive comment sections on every published post.

๐Ÿ”” Notifications System

  • Real-Time Alerts: Database-driven notifications for interactions (when someone comments on your post, favorites it, or follows you).
  • Notification Dashboard: Mark individual alerts as read/unread or clear all notifications at once.

โšก Background Jobs & Processing

  • Queue-based Mailing: Background processing of automated emails (e.g., SendNewPostsSummary).
  • Async Notifications: System notifications are dispatched asynchronously via queues to ensure blazing-fast UI response times (SendNotification job).

๐Ÿ”’ Security Features

  • Route Authorization: Comprehensive use of Laravel Gates and Policies (UserPolicy, PostPolicy) to ensure users only modify their own data.
  • Sanctum API Protection: Built-in support for secure API token generation using Laravel Sanctum (personal_access_tokens).
  • CSRF & XSS Protection: Full cross-site request forgery and cross-site scripting prevention.

๐Ÿ› ๏ธ Technologies Used

Technology Purpose / Role
PHP 8.3 Core backend language utilizing the latest features and types.
Laravel 13.x The MVC framework handling routing, ORM, requests, and security.
MySQL Relational database management system.
Tailwind CSS v4 Utility-first frontend styling framework.
Vite Lightning-fast frontend build tool and hot module replacement.
Vanilla JavaScript DOM manipulation and client-side API requests.
Google Gemini API Autonomous AI content generation (gemini-2.5-flash).
Laravel Fortify Headless backend authentication logic.
Laravel Sanctum API authentication and token management.
Composer / NPM Package managers for backend and frontend dependencies.

๐Ÿ—๏ธ System Architecture

The application is built on a strictly decoupled architecture, extending beyond standard MVC by utilizing Actions, Services, and Events to keep controllers exceptionally clean and maintainable.

  • MVC Pattern: The core of the application utilizing Models, Views (Blade), and Controllers.
  • Service Layer: Abstracted complex business logic (e.g., PostService) for creating and managing posts.
  • Actions Pattern: Single-responsibility classes handling specific tasks like FileUpload for handling cover images and SyncPostTags for managing many-to-many tag relationships.
  • Events & Listeners: A robust event-driven architecture. For example, viewing a post triggers a PostViewed event, which is handled asynchronously by an IncrementPostViews listener.
  • Jobs: Background tasks like SendNewPostsSummary handle heavy lifting off the main web thread.
  • Policies: Authorization logic is strictly isolated in classes like PostPolicy and UserPolicy.

๐Ÿ—„๏ธ Database Design

The relational database is highly normalized and relies heavily on Eloquent relationships (One-to-Many, Many-to-Many, and Polymorphic).

Main Entities

  • users: Core identity table (includes Two-Factor Auth, Passkeys, and Activity tracking).
  • posts: The primary content table (includes metadata, soft deletes, and status tracking).
  • categories & tags: Taxonomy tables for organizing posts.
  • comments: Relates to both Users (authors) and Posts.
  • roles: RBAC entity.

Pivot / Interaction Tables

  • post_tag: Many-to-Many relationship between posts and tags.
  • favorites: Many-to-Many mapping for users "liking" posts.
  • bookmarks: Many-to-Many mapping for users saving posts.
  • followers: Self-referential Many-to-Many mapping linking users to other users.
  • role_user: Maps users to specific administrative roles.

๐Ÿ“‚ Project Structure

โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ Actions/            # Single-responsibility logic (FileUpload, SyncPostTags)
โ”‚   โ”œโ”€โ”€ Events/             # Application events (PostViewed)
โ”‚   โ”œโ”€โ”€ Http/Controllers/   # Request handlers (AiController, PostController)
โ”‚   โ”œโ”€โ”€ Http/Requests/      # Form validation and sanitation rules
โ”‚   โ”œโ”€โ”€ Jobs/               # Queued background tasks (SendNewPostsSummary)
โ”‚   โ”œโ”€โ”€ Listeners/          # Event handlers (IncrementPostViews)
โ”‚   โ”œโ”€โ”€ Models/             # Eloquent ORM Models and Scopes
โ”‚   โ”œโ”€โ”€ Notifications/      # Database notification classes (FollowNotification)
โ”‚   โ”œโ”€โ”€ Policies/           # Authorization logic (PostPolicy)
โ”‚   โ””โ”€โ”€ Services/           # Business logic abstraction (PostService)
โ”œโ”€โ”€ database/               
โ”‚   โ””โ”€โ”€ migrations/         # Database schema definitions
โ”œโ”€โ”€ resources/
โ”‚   โ”œโ”€โ”€ css/                # Tailwind CSS configurations
โ”‚   โ”œโ”€โ”€ js/                 # Client-side JavaScript
โ”‚   โ””โ”€โ”€ views/              # Blade templating files (Dashboard, Auth)
โ”œโ”€โ”€ routes/                 # Web, API, and Console route definitions
โ””โ”€โ”€ tests/                  # PHPUnit Feature and Unit tests

๐Ÿค– AI Workflow (Under the Hood)

Write AI integrates seamlessly with Google's Gemini models:

  1. User Prompt: A user submits a topic via the Dashboard (AiController).
  2. System Injection: The backend formulates a strict system prompt requiring the AI to act as an SEO specialist and format the output exclusively as a specific JSON schema.
  3. Execution: The request is sent asynchronously to the Gemini API (gemini-2.5-flash).
  4. Parsing: The Controller catches the response, strips markdown wrappers, decodes the JSON, and safely populates the post creation form dynamically on the frontend.

๐Ÿš€ Installation Guide

1. Clone the repository

git clone https://github.com/yourusername/write-ai.git
cd write-ai

2. Install Dependencies

composer install
npm install

3. Environment Configuration

cp .env.example .env
php artisan key:generate

4. Database Setup (MySQL)

Create a new MySQL database for the project. Open your .env file and configure the connection:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=root
DB_PASSWORD=your_password

5. Run Migrations

php artisan migrate
# Or to include seeders: php artisan migrate --seed

6. Link Local Storage (Crucial for Images)

php artisan storage:link

7. Run the Application

Compile the frontend assets and start the server concurrently:

# This command runs Laravel Serve, Vite, and the Queue Worker simultaneously
composer dev 

Visit http://localhost:8000 in your browser.


๐Ÿ”‘ Environment Variables

The following variables in the .env file are crucial for the application to function:

APP_NAME="Write AI"
APP_URL=http://localhost:8000

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=

# Gemini AI Configuration
GEMINI_API_KEY=your_gemini_api_key
GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta
GEMINI_MODEL=gemini-2.5-flash

# Queue & Cache
QUEUE_CONNECTION=database
CACHE_STORE=database

โšก Performance Optimizations

  • Eager Loading: Used extensively in controllers (e.g., Post::with('category', 'user')) to eradicate the N+1 query problem.
  • Asynchronous Queues: Email dispatching and notification generation are pushed to the database queue rather than holding up the HTTP response.
  • Event-Driven Counters: Page views are handled via the PostViewed event rather than synchronous database writes during page loads.

๐Ÿ“ธ Screenshots

(Add paths to your local images here)

Home Page
AI Dashboard
Post Details


๐Ÿงช Testing

The application is thoroughly tested using PHPUnit. To run the test suite:

# Clear caches and run tests
composer test

# Or using artisan
php artisan test

๐ŸŒ Deployment

For production deployment, run the following commands:

composer install --optimize-autoloader --no-dev
php artisan config:cache
php artisan route:cache
php artisan view:cache
npm run build

# Ensure the queue worker is running via Supervisor or similar
php artisan queue:work

โŒจ๏ธ Available Artisan Commands

php artisan migrate                # Run database migrations
php artisan migrate:fresh --seed   # Reset database and seed fake data
php artisan storage:link           # Link public storage directory
php artisan queue:listen           # Start processing background jobs
php artisan optimize:clear         # Clear all application caches
php artisan route:list             # View all registered endpoints

๐Ÿ”ฎ Future Improvements

  • Implementation of Redis for faster caching and queue management.
  • OAuth Social Login integrations (Google, GitHub) via Laravel Socialite.
  • Detailed reporting and analytics dashboard for authors.
  • Enhanced AI features including automated image generation for post covers.

๐Ÿค Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“œ License

Distributed under the MIT License. See LICENSE for more information.


๐Ÿ™ Credits

About

A full-featured AI-powered blogging platform built with Laravel, featuring AI content generation, content interactions, bookmarks, follow system, notifications, REST APIs, and an elegant dashboard for seamless content management.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages