A modern, full-featured code snippet management system built with Laravel 12 and Livewire 3, designed to help developers store, organize, search, and reuse knowledge efficiently with a fast, reactive user experience.
Developers constantly save useful code snippets across notes, chats, and scattered files, making them difficult to search, reuse, or share later.
This project solves that problem by providing a centralized, searchable, and tag-based snippet manager with real-time validation, syntax highlighting, strong authorization rules, and performance-focused architecture.
It was built to explore complex Livewire-driven UIs, clean backend architecture, and production-ready Laravel patterns.
- Create & Manage Snippets – Write, edit, and organize code snippets
- Code Highlighting – Syntax highlighting for 200+ languages using CodeMirror and Highlight.js
- Smart Tagging – Autocomplete-based tag system for easy categorization
- Advanced Filtering – Search by title, language, tags, and visibility
- Public / Private Control – Share snippets publicly or keep them private
- Like/Upvote System – Like public snippets and discover the most popular ones
- Export Options – Download snippets as JSON or PDF
- Livewire 3 – Reactive UI without custom JavaScript
- Real-time Validation – Instant feedback with visual indicators
- Dark Mode Support – Fully implemented across all components
- Mobile Responsive – Optimized for all screen sizes
- Performance Optimized – Laravel Octane with Swoole
- Database Optimization – Indexing, eager loading, and N+1 query prevention
app/
├── Http/
│ ├── Controllers/
│ ├── Middleware/
│ └── Requests/
├── Livewire/
│ ├── SnippetsIndex.php
│ ├── MySnippets.php
│ ├── CreateSnippet.php
│ ├── EditSnippet.php
│ ├── TagAutocomplete.php
│ └── DeleteSnippet.php
└── Models/
├── Snippet.php
├── Tag.php
└── User.php
resources/views/
├── livewire/
│ ├── snippets-index.blade.php
│ ├── my-snippets.blade.php
│ ├── create-snippet.blade.php
│ ├── edit-snippet.blade.php
│ ├── tag-autocomplete.blade.php
│ └── delete-snippet.blade.php
└── snippets/
├── index.blade.php
├── my.blade.php
├── create.blade.php
└── edit.blade.php
-
SnippetsIndex
- Lists all public snippets and the authenticated user's snippets
- Search by title
- Filtering by language, tags, and visibility
- Pagination
- Bulk export
- Delete with confirmation
-
MySnippets
- Displays only the authenticated user's snippets
- Same filtering and pagination
- Private snippet management
-
CreateSnippet
- Snippet creation form featuring:
- CodeMirror integration
- Real-time validation with visual indicators
- Tag autocomplete
- Language selection
-
EditSnippet
- Edit existing snippets
- Pre-filled form
- Authorization checks
- Delete with confirmation
-
TagAutocomplete
- Reusable component providing:
- Real-time tag suggestions
- Add/remove tag functionality
-
DeleteSnippet
- Confirmation modal for deletion
- Authorization verification
- Dark mode compatible UI
-
LikeSnippet
- Like/upvote button for public snippets
- Displays total likes count
- Toggle like/unlike with visual feedback
- Only authenticated users can like snippets
- Each user can like a snippet only once
- Real-time update of like status
-
SaveSnippet
- Save/bookmark button for public snippets
- Toggle save/unsave with a single click
- Visual bookmark icon with saved state
- Only authenticated users can save snippets
- Each user can save a snippet only once
- Saved snippets accessible on dedicated page
The application includes a comprehensive like/upvote system for public snippets:
- Like Public Snippets – Authenticated users can like publicly shared snippets to show appreciation
- One Like Per User – Database constraint ensures each user can like a snippet only once
- Like Count Display – Each snippet displays the total number of likes
- Like-Based Sorting – Snippets can be sorted by most liked to discover popular code
- Visual Feedback – Like button changes appearance when liked (filled heart icon and red color)
- Toggle like/unlike with a single click
- Like count updates in real-time
- Like button only appears on public snippets
- Unlike reverts the like with one more click
- Dashboard view includes "Most Liked" sorting option for both public and personal snippets
The dashboard provides a comprehensive overview and quick access to key information:
-
Left Column: Top Snippets – Displays the 5 most-liked public snippets ranked by likes
- Ranked with badge numbers (1-5)
- Shows title, language, tags, and description
- Displays author, like count, lines of code, and creation date
- Quick save and view buttons for each snippet
-
Right Column: Top Contributors – Shows the 5 most active contributors
- Ranked by number of public snippets created
- Displays contributor name and email
- Shows count of public snippets contributed
- Real-time ranking based on likes and contributions
- Responsive two-column layout (single column on mobile)
- Quick access to popular content and top community members
- Save button to bookmark interesting snippets directly from dashboard
Users can save and bookmark public snippets for quick access later:
- Save Button – Appears on all public snippets with a bookmark icon
- Visual Feedback – Icon fills when saved, shows "Saved" text
- Dedicated Page – View all saved snippets on the "Saved Snippets" tab
- Full Features – Like, export, and view saved snippets
- Private Collection – Each user's saved snippets are completely private
- One Save Per Snippet – Database constraint ensures each user can only save a snippet once
- Toggle save/unsave with a single click
- Saved snippets appear in chronological order (newest first)
- Full snippet details including code, tags, and description
- Export saved snippets as JSON or PDF
- Combined view with both saved and liked snippets in convenient location
All features require authentication. Authorization checks:
- Users can edit and delete only their own snippets
- Public snippets are visible to all authenticated users
- Private snippets are visible only to their owner
- Any authenticated user can create tags
- Any authenticated user can like public snippets
The application provides a RESTful API with token-based authentication (Laravel Sanctum).
POST /api/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password"
}Response (200 OK):
{
"message": "Login successful",
"token": "1|abcdef...",
"user": {
"id": 1,
"name": "John Doe",
"email": "user@example.com"
}
}POST /api/logout
Authorization: Bearer <token>Response (200 OK):
{
"message": "Logout successful"
}All endpoints below require Authorization: Bearer <token> header.
GET /api/snippetsGET /api/snippets/{id}POST /api/snippets
Content-Type: application/json
{
"title": "Example Snippet",
"language": "php",
"code": "<?php echo 'Hello'; ?>",
"is_public": true
}PUT /api/snippets/{id}
Content-Type: application/json
{
"title": "Updated Title",
"language": "php",
"code": "<?php echo 'Updated'; ?>",
"is_public": true
}DELETE /api/snippets/{id}These endpoints do not require authentication.
GET /api/public/snippetsGET /api/public/snippets/{slug}The project includes comprehensive API tests in tests/Feature/AuthApiTest.php and tests/Feature/SnippetApiTest.php.
Run API tests:
php artisan test tests/Feature/AuthApiTest.php
php artisan test tests/Feature/SnippetApiTest.phpOr run all tests:
php artisan testCREATE TABLE snippets (
id bigint PRIMARY KEY,
user_id bigint REFERENCES users(id),
title varchar(255) NOT NULL,
description text,
code longtext NOT NULL,
language varchar(50),
is_public boolean DEFAULT false,
created_at timestamp,
updated_at timestamp
);
CREATE INDEX idx_user_id ON snippets(user_id);
CREATE INDEX idx_is_public ON snippets(is_public);CREATE TABLE tags (
id bigint PRIMARY KEY,
name varchar(255) UNIQUE NOT NULL,
created_at timestamp,
updated_at timestamp
);CREATE TABLE snippet_tag (
snippet_id bigint REFERENCES snippets(id) ON DELETE CASCADE,
tag_id bigint REFERENCES tags(id) ON DELETE CASCADE,
PRIMARY KEY (snippet_id, tag_id)
);- Framework: Laravel 12
- Reactive UI: Livewire 3.7.1
- Code Editor: CodeMirror 5.65.2
- Syntax Highlighting: Highlight.js 11.9.0
- Export: DOMPDF 3.1.1
- Performance: Laravel Octane + Swoole
- Database: MySQL 8.0+
- Cache: Redis
- Styling: Tailwind CSS
- Frontend: Alpine.js (via Livewire)
- PHP 8.2+
- MySQL 8.0+
- Composer
- Node.js & npm
-
Clone the repository
git clone <repository-url> cd DeveloperKnowledgeSnippetManager
-
Install dependencies
composer install npm install
-
Environment setup
cp .env.example .env php artisan key:generate
-
Configure database (in
.env)DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=snippet_manager DB_USERNAME=root DB_PASSWORD= -
Run migrations
php artisan migrate
-
Build assets
npm run build
-
Start the development server
php artisan serve
-
Start Octane (optional, for production-like performance)
php artisan octane:start --workers=1
Visit http://localhost:8000 and register a new account.
Comprehensive testing documentation is available:
- PHASE_6_TESTING_GUIDE.md - 70+ test scenarios with step-by-step procedures
- MASTER_TESTING_CHECKLIST.md - 150+ items organized by feature
- PHASE_6_TESTING_SUMMARY.md - Test matrices and execution plan
Run automated test suite:
php test_livewire_e2e.phpOr via Tinker:
php artisan tinker < test_livewire_e2e.php- README.md - This file (project overview)
- LIVEWIRE_QUICK_REFERENCE.md - Developer reference guide
- SETUP_INSTRUCTIONS.md - Detailed setup and configuration
- DEPLOYMENT_GUIDE.md - Production deployment steps
- PERFORMANCE_OPTIMIZATION_SUMMARY.md - Optimization details
- PERFORMANCE_QUICK_REFERENCE.md - Performance tips
- OCTANE_IMPLEMENTATION.md - Octane configuration
For production-like performance testing:
php artisan octane:start --workers=1View Octane config in config/octane.php
Dark mode is automatically detected from system preferences and can be toggled in the UI.
Typical performance with Octane (1 worker):
- List page load: < 500ms
- Create/Edit page load: < 400ms
- Real-time validation: < 100ms response
- Export small snippet: < 1s
- Export all snippets: < 5s
See PERFORMANCE_QUICK_REFERENCE.md for optimization tips.
- Update Livewire component in
app/Livewire/ - Update corresponding view in
resources/views/livewire/ - Run tests:
php test_livewire_e2e.php
- Create new Livewire component:
php artisan make:livewire FeatureName - Implement component logic
- Create/update corresponding blade view
- Add tests to test suite
For production deployment:
- Follow DEPLOYMENT_GUIDE.md
- Set environment to production:
APP_ENV=production - Run migrations:
php artisan migrate --force - Generate API docs if needed
- Configure SSL certificates
- Set up monitoring and logging
Current Phase: Phase 7 - Cleanup & Documentation
Livewire Migration: Complete (Phases 1-6)
Testing Infrastructure: Complete (Phase 6)
Status: Production Ready








