← Back to Portfolio
Case Study — Real-Time Full-Stack App

Multi-User
Real-Time Chat

A Laravel 13 API with a Vue 3 single-page app: Sanctum token auth, direct and group conversations, file attachments, unread tracking and typing indicators over self-hosted WebSockets. No paid services required.

Laravel 13 Sanctum Laravel WebSockets Vue 3 + Pinia Vite SQLite / MySQL ▶ Personal Project · 2024 to 2026
$0 Paid Services
2 Conversation Types
4 API Controllers
2 Broadcast Events
01 — The Goal

Real-Time Chat Without a Vendor Bill

Most tutorials reach for a paid push service. This project does it with free, self-hosted parts.

💬

Real chat features

Direct and group conversations, attachments, unread counts and typing indicators, not just a message box.

🔓

Private by design

Only members of a conversation can read it, write to it, or listen to its channel.

💰

Free to run

A Pusher-compatible WebSocket server runs inside the app's own stack, so there are no per-message fees.

02 — Architecture

How It Fits Together

A REST API for actions and a WebSocket channel for live updates.

Client
Vue 3 SPA Pinia stores: auth, chat Laravel Echo
↓ REST /api/v1 with Sanctum token
API
throttle:api auth:sanctum Auth · Profile · Conversation · Message controllers
↓ Eloquent
Data
users conversations conversation_user (role, last_read_at) messages
↓ broadcast events
Realtime
MessageSent Typing Laravel WebSockets (ws:6001)
↓ to channel members
Clients
Private channel per conversation Presence channel for typing
03 — Features

What It Does

What the code implements.

🔑

Auth and profiles

Email and password sign-in with Sanctum tokens, plus profile status and avatar upload.

👥

Conversations

Direct and group conversations with member roles.

⚡

Live messages

New messages are broadcast to other members as they are sent.

📎

Attachments

Files up to 5 MB, validated and stored locally with a public link.

👀

Unread tracking

Each member has a last-read timestamp per conversation.

✍️

Typing indicator

A typing event is sent to other members of the conversation.

04 — Technology

Technology Choices

First-party and free components throughout.

LayerTechnologyWhy
Backend Laravel 13 Mature routing, validation, Eloquent models and broadcasting.
Auth Laravel Sanctum Simple personal access tokens for a SPA and API.
Realtime beyondcode/laravel-websockets A self-hosted, Pusher-compatible server, so no external service is needed.
Frontend Vue 3 + Pinia + Vite A small SPA with centralized auth and chat state.
Database SQLite, or MySQL / PostgreSQL SQLite for a one-command start; a production database through the .env file.
Tooling Docker Compose, GitHub Actions Optional MySQL, Redis and Mailhog, and workflow files for tests.
05 — Decisions

Calls That Mattered

The design choices that shape how the app behaves.

01

Self-hosted WebSockets

Using a Pusher-compatible server inside the stack removes per-message cost and keeps everything runnable locally.

02

A pivot table that carries role and read state

conversation_user stores each member's role and last_read_at, so membership, permissions and unread counts come from one place.

03

Check membership on every conversation endpoint

Each controller action first verifies the user belongs to the conversation, and returns 403 if not.

04

Save the message and the read marker together

Creating a message and updating the sender's last_read_at happen in one database transaction.

05

Broadcast to others only

Events are sent with toOthers(), so the sender's own client does not receive a duplicate of its message.

06 — Hard Parts

What Needed Care

The design problems in a real-time app.

🔒 Authorising live channels

Channels need their own authorisation, separate from HTTP routes. Channel callbacks check that the user is a participant of the conversation before they can listen.

✓ Participation checks per channel

👀 Unread state

Unread counts depend on who has seen what. A last_read_at per member and a mark-as-read endpoint keep it simple and cheap.

✓ Per-member read timestamp

📎 Safe attachments

Uploads are validated by size, stored under a controlled path and returned with a computed URL.

✓ Validation and controlled storage

🔄 Typing without noise

Typing is sent through a lightweight endpoint to a presence channel, kept separate from message storage.

✓ Separate event, no persistence
07 — Outcomes

What This Demonstrates

What the repository shows.

$0 Paid services Auth, sockets, storage and queues all use free first-party or self-hosted parts.
REST + WS Two channels A versioned REST API plus WebSocket events for live updates.
2 Events MessageSent and Typing broadcast to conversation members.
CI Workflows GitHub Actions workflow files for tests are included.
Docker Optional stack A compose file for MySQL, Redis and Mailhog.
v1 Versioned API All endpoints live under /api/v1 with rate limiting.
08 — Limits

Known Limits and What Is Next

Where the project still needs work.

🧪

Tests are minimal

The test suite is still the framework's default example tests. Feature tests for auth, membership and messages are the first priority.

🔍

Missing chat features

Message search, reactions, editing and deleting messages, and moderation tools.

📐

What I would build next

Web push notifications, stricter throttling, and a CI pipeline that runs the new tests.

Available for work

Want to build something
like this together?

I'm open to full-time roles and project work in AI engineering, full-stack development, and backend systems.