Skip to content

crindalwalt/TaskLine

Repository files navigation

Taskline API Backend

A robust REST API backend for Taskline - a project management focused todo system built with Laravel 12 and Sanctum for token-based authentication.

Features

  • Token-Based Authentication - Secure API authentication using Laravel Sanctum
  • User Management - Register, login, logout functionality
  • Project Management - Create, read, update, delete projects with team collaboration
  • Task Management - Full CRUD operations with priorities, status tracking, and due dates
  • Dashboard API - Aggregated stats, today's tasks, and project overview

Requirements

  • PHP 8.2+
  • Composer
  • SQLite/MySQL/PostgreSQL

Installation

# Clone the repository
git clone <repository-url>
cd taskline

# Install dependencies
composer install

# Copy environment file
cp .env.example .env

# Generate application key
php artisan key:generate

# Create database (SQLite)
touch database/database.sqlite

# Run migrations
php artisan migrate

# Seed database with demo data
php artisan db:seed

# Start development server
php artisan serve

Demo Users

After seeding, you can use these credentials:

Email Password Role
john@taskline.com password123 Main Demo User
alice@taskline.com password123 Designer
bob@taskline.com password123 Backend Developer
carol@taskline.com password123 Manager

API Endpoints

Base URL: http://localhost:8000/api

Authentication

All protected endpoints require the Authorization: Bearer <token> header.

Register User

POST /auth/register
Content-Type: application/json

{
    "name": "John Doe",
    "email": "john@example.com",
    "password": "password123",
    "password_confirmation": "password123"
}

Response: { success, message, data: { user, token } }

Login

POST /auth/login
Content-Type: application/json

{
    "email": "john@taskline.com",
    "password": "password123"
}

Response: { success, message, data: { user, token } }

Logout (Protected)

POST /auth/logout
Authorization: Bearer <token>

Response: { success, message }

Get Current User (Protected)

GET /auth/user
Authorization: Bearer <token>

Response: { success, data: { id, name, email } }

Dashboard (Protected)

Get Dashboard Data (Home Screen)

GET /dashboard
Authorization: Bearer <token>

Response: {
    success: true,
    data: {
        user_name: "John Developer",
        total_tasks: 6,
        stats: [
            { label: "pending", count: 5 },
            { label: "in_progress", count: 0 },
            { label: "completed", count: 1 }
        ],
        projects: [
            { id, name, description, progress }
        ],
        todays_tasks: [
            { id, title, due_date, done }
        ]
    }
}

Projects (Protected)

List Projects

GET /projects
Authorization: Bearer <token>

Response: {
    success: true,
    data: {
        total_projects: 3,
        projects: [
            {
                id, title, description,
                team: [{ id, name, email }],
                owner: { id, name },
                progress, status
            }
        ]
    }
}

Create Project

POST /projects
Authorization: Bearer <token>
Content-Type: application/json

{
    "title": "New Project",
    "description": "Project description",
    "team": [2, 3]  // Optional user IDs for team members
}

Response: { success, message, data: { project } }

Get Project Detail

GET /projects/{id}
Authorization: Bearer <token>

Response: { success, data: { project with tasks_count } }

Update Project

PUT /projects/{id}
Authorization: Bearer <token>
Content-Type: application/json

{
    "title": "Updated Title",
    "description": "Updated description",
    "status": "active|completed|archived",
    "team": [2, 3, 4]
}

Response: { success, message, data: { project } }

Delete Project

DELETE /projects/{id}
Authorization: Bearer <token>

Response: { success, message }

Tasks (Protected)

List Tasks

GET /tasks
GET /tasks?project_id=1
GET /tasks?status=pending
GET /tasks?priority=high
Authorization: Bearer <token>

Response: {
    success: true,
    data: {
        total_tasks: 12,
        tasks: [
            {
                id, title, description, due_date,
                assigned_to: { id, name },
                priority, status, is_done,
                project: { id, title }
            }
        ]
    }
}

Create Task

POST /tasks
Authorization: Bearer <token>
Content-Type: application/json

{
    "title": "New Task",
    "description": "Task description",
    "project_id": 1,
    "due_date": "2026-02-15",
    "assigned_to": 1,
    "priority": "high|medium|low"
}

Response: { success, message, data: { task } }

Get Task Detail

GET /tasks/{id}
Authorization: Bearer <token>

Response: {
    success: true,
    data: {
        id, title, description, due_date,
        assigned_to: { id, name, email },
        created_by: { id, name },
        priority, status, is_done,
        project: { id, title },
        created_at, updated_at
    }
}

Update Task

PUT /tasks/{id}
Authorization: Bearer <token>
Content-Type: application/json

{
    "title": "Updated Task",
    "description": "Updated description",
    "due_date": "2026-02-20",
    "assigned_to": 2,
    "priority": "medium",
    "status": "in_progress",
    "is_done": false
}

Response: { success, message, data: { task } }

Toggle Task Done Status

PATCH /tasks/{id}/toggle-done
Authorization: Bearer <token>

Response: { success, message, data: { id, is_done, status } }

Delete Task

DELETE /tasks/{id}
Authorization: Bearer <token>

Response: { success, message }

Data Models

User

  • id, name, email, password, email_verified_at, created_at, updated_at

Project

  • id, title, description, owner_id, progress (0-100%), status (active/completed/archived), created_at, updated_at

Task

  • id, title, description, project_id, assigned_to, created_by, priority (low/medium/high), status (pending/in_progress/completed), due_date, is_done, created_at, updated_at

Testing with cURL

# Login and get token
TOKEN=$(curl -s -X POST http://localhost:8000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"john@taskline.com","password":"password123"}' | jq -r '.data.token')

# Get dashboard
curl -s http://localhost:8000/api/dashboard \
  -H "Authorization: Bearer $TOKEN" | jq .

# Get projects
curl -s http://localhost:8000/api/projects \
  -H "Authorization: Bearer $TOKEN" | jq .

# Create task
curl -s -X POST http://localhost:8000/api/tasks \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"New Task","project_id":1,"priority":"high"}' | jq .

Project Structure

app/
├── Http/Controllers/Api/
│   ├── AuthController.php      # Authentication endpoints
│   ├── DashboardController.php # Dashboard/Home screen data
│   ├── ProjectController.php   # Project CRUD operations
│   └── TaskController.php      # Task CRUD operations
├── Models/
│   ├── User.php               # User model with relationships
│   ├── Project.php            # Project model
│   └── Task.php               # Task model
database/
├── factories/                 # Model factories for testing
├── migrations/                # Database schema
└── seeders/
    └── DatabaseSeeder.php     # Strategic demo data
routes/
└── api.php                    # API route definitions

License

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

About

Taskline - Task management app

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors