Skip to content

larsb-dev/to-do-list-app

Repository files navigation

Laravel Task Management Tool

A modern, full-featured todo list application built with Laravel 12, demonstrating best practices in web development including authentication, authorization, CRUD operations, and pagination with filtering.

Laravel PHP TailwindCSS Alpine.js

πŸ“‹ Features

Core Functionality

  • βœ… CRUD Operations - Create, Read, Update, and Delete todos
  • 🎯 Status Management - Track todos with three states: Not Started, In Progress, and Completed
  • πŸ” Filtering - Filter todos by status with query string preservation
  • πŸ“„ Pagination - Simple pagination with 9 items per page
  • ⚑ Quick Complete - Mark todos as completed with a single click

Authentication & Authorization

  • πŸ” User Authentication - Secure login and registration system
  • πŸ‘€ Role-Based Access Control (RBAC) - Custom middleware for role authorization
  • πŸ›‘οΈ Custom Authentication Middleware - EnsureUserIsAuthenticated and EnsureUserHasRole
  • πŸšͺ Protected Routes - Guest and authenticated route groups

Technical Highlights

  • πŸš€ Optimized Queries - Eager loading to prevent N+1 problems
  • 🎨 Modern UI - Built with TailwindCSS 4.0 and Alpine.js
  • 🧩 Blade Components - Reusable UI components
  • βœ… Form Validation - Server-side validation with Laravel's validation system
  • πŸ§ͺ Testing Ready - Configured with Pest PHP for testing
  • πŸ› Debug Toolbar - Laravel Debugbar for development

πŸ› οΈ Tech Stack

Backend

  • Laravel 12 - PHP framework
  • PHP 8.2+ - Programming language
  • SQLite - Database (easily switchable to MySQL/PostgreSQL)
  • Eloquent ORM - Database abstraction

Frontend

  • TailwindCSS 4.0 - Utility-first CSS framework
  • Alpine.js 3.15 - Lightweight JavaScript framework
  • Vite 7.0 - Frontend build tool
  • Blade Templates - Laravel's templating engine

Development Tools

  • Pest PHP 4.3 - Testing framework
  • Laravel Pint - Code style fixer
  • Laravel Debugbar - Debugging tool
  • Laravel Pail - Log viewer
  • Concurrently - Run multiple dev processes

πŸ“¦ Installation

Prerequisites

  • PHP 8.2 or higher
  • Composer
  • Node.js 18+ and npm
  • SQLite (or MySQL/PostgreSQL if you prefer)

Quick Setup

# Clone the repository
git clone <your-repository-url>
cd to-do-list-app

# Install dependencies and setup
composer setup

# This runs:
# - composer install
# - Copies .env.example to .env
# - Generates application key
# - Runs migrations
# - npm install
# - npm run build

Manual Setup

If you prefer to set up manually:

# Install PHP dependencies
composer install

# Copy environment file
cp .env.example .env

# Generate application key
php artisan key:generate

# Create SQLite database file
touch database/database.sqlite

# Run migrations
php artisan migrate

# Seed the database (optional)
php artisan db:seed

# Install Node dependencies
npm install

# Build frontend assets
npm run build

πŸš€ Running the Application

Development Mode (Recommended)

Run all development services with a single command:

composer run dev

This runs concurrently:

  • Laravel development server (http://localhost:8000)
  • Queue listener
  • Log viewer (Pail)
  • Vite dev server (Hot Module Replacement)

πŸ“– Usage

Default User

After running the seeder, you can log in with:

Managing Todos

  1. Create a Todo

    • Click "Add New Todo" button
    • Fill in the title, description, and select a status
    • Submit the form
  2. Filter Todos

    • Use the status filter buttons to view todos by status
    • URL will reflect the current filter (e.g., ?status=not_started)
  3. Edit a Todo

    • Click the "Edit" button on any todo card
    • Modify the details and save
  4. Complete a Todo

    • Click the "Mark Complete" button to instantly set status to Completed
  5. Delete a Todo

    • Click the "Delete" button and confirm

Status Types

  • Not Started - Todo hasn't been started yet
  • In Progress - Currently working on the todo
  • Completed - Todo is finished

πŸ—οΈ Project Structure

β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ Http/
β”‚   β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   β”‚   β”œβ”€β”€ Auth/           # Authentication controllers
β”‚   β”‚   β”‚   └── TodoController.php
β”‚   β”‚   └── Middleware/
β”‚   β”‚       β”œβ”€β”€ EnsureUserHasRole.php
β”‚   β”‚       └── EnsureUserIsAuthenticated.php
β”‚   └── Models/
β”‚       β”œβ”€β”€ Status.php          # Status model with constants
β”‚       β”œβ”€β”€ Todo.php            # Todo model
β”‚       └── User.php            # User model with role support
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ factories/              # Model factories
β”‚   β”œβ”€β”€ migrations/             # Database migrations
β”‚   └── seeders/                # Database seeders
β”œβ”€β”€ resources/
β”‚   β”œβ”€β”€ css/
β”‚   β”œβ”€β”€ js/
β”‚   └── views/
β”‚       β”œβ”€β”€ auth/               # Authentication views
β”‚       β”œβ”€β”€ components/         # Blade components
β”‚       β”œβ”€β”€ layouts/            # Layout templates
β”‚       └── todos/              # Todo views
└── routes/
    β”œβ”€β”€ auth.php                # Authentication routes
    └── web.php                 # Web routes

πŸ”‘ Key Features Explained

Authentication System

Custom authentication implementation with:

  • Registration with name, email, and password
  • Login/logout functionality
  • Protected routes using middleware
  • Session-based authentication

Authorization

Role-based access control with:

  • hasRole() method on User model
  • EnsureUserHasRole middleware with role parameter
  • Example: middleware('role:admin') in routes

Optimized Database Queries

// Eager loading to prevent N+1 problems
Todo::with('status')->select(['id', 'title', 'description', 'status_id']);

Query String Preservation

Pagination maintains filter parameters:

$todos->simplePaginate(9)->withQueryString();

🎨 Customization

Changing Database

Edit .env to use MySQL or PostgreSQL:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password

Adjusting Pagination

Edit TodoController.php:

// Change from 9 to your preferred number
$todos = $todos->simplePaginate(9)->withQueryString();

Adding More Statuses

Add constants to app/Models/Status.php and create a migration to add the new status to the database.

πŸ› Known Issues & Future Improvements

Current Known Issues

  • Pagination doesn't preserve filter query strings βœ… FIXED with withQueryString()

Future Enhancements

  • Deployment with Docker Compose
  • User-specific todos (multi-tenancy)
  • Due dates and reminders
  • Search functionality
  • Email notifications
  • Export todos (PDF/CSV)

πŸ“ Code Style

This project follows Laravel conventions and uses:

  • PSR-12 coding standard
  • Laravel Pint for automatic code formatting

Format code with:

./vendor/bin/pint

🀝 Contributing

This is a learning/portfolio project. Feel free to fork and experiment!

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (composer test)
  5. Format code (./vendor/bin/pint)
  6. Commit changes (git commit -m 'Add amazing feature')
  7. Push to branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

πŸ“„ License

This project is open-sourced software licensed under the MIT license.

πŸ‘¨β€πŸ’» Author

Built as a learning project to demonstrate:

  • Laravel 12 framework capabilities
  • Modern PHP development practices
  • Authentication and Authorization (AuthN/AuthZ)
  • RESTful resource controllers
  • Database optimization techniques
  • Frontend integration with TailwindCSS and Alpine.js

Note: This project is designed to be junior developer friendly, showcasing fundamental concepts in web development including authentication (AuthN) and authorization (AuthZ), CRUD operations, and best practices in Laravel development.

About

Full-stack Laravel app with authentication for managing tasks

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages