A Laravel-based RESTful API for project collaboration and task management. This API enables teams to create projects, manage tasks, invite members, and collaborate effectively with role-based access control and email notifications.
- User Authentication: Secure registration, login, and logout using Laravel Sanctum
- Project Management: Create, read, update, and delete projects
- Task Management: Full CRUD operations for tasks with filtering capabilities
- Team Collaboration: Invite members to projects with role-based permissions
- Role-Based Access Control: Three roles - Owner, Admin, and Member
- Email Notifications: Automated emails for task creation, updates, invitations, and welcome messages
- Task Filtering: Filter tasks by priority (low/high) and status (pending/in_progress/completed)
- Authorization Policies: Granular permissions using Laravel Policies
- Event-Driven Architecture: Events and listeners for email notifications
- Framework: Laravel 12.x
- PHP: ^8.2
- Authentication: Laravel Sanctum
- Database: SQLite (default, can be configured for MySQL/PostgreSQL)
- Email: Laravel Mail (with queue support)
- Monitoring: Laravel Telescope
- Frontend Assets: Vite with Tailwind CSS
- PHP >= 8.2
- Composer
- Node.js and npm
- SQLite (or MySQL/PostgreSQL)
-
Clone the repository
git clone <repository-url> cd collab
-
Install PHP dependencies
composer install
-
Install Node dependencies
npm install
-
Environment setup
cp .env.example .env php artisan key:generate
-
Configure database
- Update
.envfile with your database credentials - For SQLite, ensure
database/database.sqliteexists:touch database/database.sqlite
- Update
-
Run migrations
php artisan migrate
-
Configure mail settings (optional, for email notifications)
- Update mail configuration in
.env:MAIL_MAILER=smtp MAIL_HOST=your-smtp-host MAIL_PORT=587 MAIL_USERNAME=your-email MAIL_PASSWORD=your-password MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=noreply@example.com MAIL_FROM_NAME="${APP_NAME}"
- Update mail configuration in
-
Start queue worker (for email notifications)
php artisan queue:work
Run the development server with all services:
composer run devThis command runs:
- Laravel development server
- Queue worker
- Laravel Pail (logs)
- Vite dev server
# Start Laravel server
php artisan serve
# In another terminal, start queue worker
php artisan queue:work
# In another terminal, start Vite (if needed)
npm run devAll authentication endpoints are prefixed with /api/auth
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/register |
Register a new user | No |
| POST | /api/auth/login |
Login user | No |
| POST | /api/auth/logout |
Logout user | Yes |
Register Request:
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123",
"password_confirmation": "password123"
}Login Request:
{
"email": "john@example.com",
"password": "password123"
}Response (Login/Register):
{
"message": "Welcome Back To The Website",
"User": {
"id": 1,
"name": "John Doe",
"email": "john@example.com"
},
"Token": "1|..."
}All project endpoints require authentication. Use the token in the Authorization header:
Authorization: Bearer {token}
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/projects |
Get all projects owned by user | Yes |
| POST | /api/projects |
Create a new project | Yes |
| GET | /api/projects/{id} |
Get a specific project | Yes |
| PUT/PATCH | /api/projects/{id} |
Update a project | Yes (Owner only) |
| DELETE | /api/projects/{id} |
Delete a project | Yes (Owner only) |
Create Project Request:
{
"name": "My New Project"
}Update Member Role:
POST /api/projects/{projectId}/members/{userId}/role
Content-Type: application/json
{
"role": "admin" // or "member"
}
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/tasks |
Get all tasks | Yes |
| POST | /api/tasks |
Create a new task | Yes |
| GET | /api/tasks/{id} |
Get a specific task | Yes |
| PUT/PATCH | /api/tasks/{id} |
Update a task | Yes |
| DELETE | /api/tasks/{id} |
Delete a task | Yes |
| GET | /api/project/{projectId}/tasks |
Get all tasks for a project | Yes |
| GET | /api/projects/{projectId}/tasks/priority/{priority} |
Get tasks by priority (low/high) | Yes |
| GET | /api/projects/{projectId}/tasks/status/{status} |
Get tasks by status (pending/in_progress/completed) | Yes |
Create Task Request:
{
"title": "Complete API documentation",
"priority": "high",
"status": "pending",
"project_id": 1,
"due_date": "2024-12-31"
}Task Priority Values: low, high
Task Status Values: pending, in_progress, completed
Note: The database migration uses
doneas the status value, but the API acceptscompleted. Ensure consistency when working with the database directly.
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/invite/{userId}/project/{projectId} |
Send invitation to user | Yes (Owner only) |
| POST | /api/invite/{projectId}/accept |
Accept invitation | Yes |
Accept Invitation:
POST /api/invite/{projectId}/accept
Content-Type: application/json
{
"token": "invitation-token-from-email"
}
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/user |
Get authenticated user info | Yes |
- Owner: Full control (view, update, delete)
- Admin: Can create, update, and delete tasks
- Member: Can view tasks (read-only)
- Project Owner: Full control over all tasks
- Admin Members: Can create, update, and delete tasks
- Regular Members: Read-only access
id,name,email,password,email_verified_at,remember_token,timestamps
id,name,owner_id,timestamps
id,title,due_date,priority(enum: low, high),status(enum: pending, in_progress, done),project_id,timestamps
id,user_id,project_id,token,status(enum: pending, accepted, declined),role(enum: member, admin),timestamps
The application sends automated emails for:
- Welcome Email: Sent when a user registers
- Task Created Email: Sent when a new task is created
- Task Updated Email: Sent when a task is updated
- Invitation Email: Sent when a user is invited to a project
Emails are queued for better performance. Make sure to run the queue worker:
php artisan queue:work-
Register a user
curl -X POST http://localhost:8000/api/auth/register \ -H "Content-Type: application/json" \ -d '{ "name": "John Doe", "email": "john@example.com", "password": "password123", "password_confirmation": "password123" }'
-
Create a project
curl -X POST http://localhost:8000/api/projects \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name": "My Project"}'
-
Create a task
curl -X POST http://localhost:8000/api/tasks \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "title": "Complete documentation", "priority": "high", "status": "pending", "project_id": 1, "due_date": "2024-12-31" }'
-
Invite a user to project
curl -X POST http://localhost:8000/api/invite/2/project/1 \ -H "Authorization: Bearer YOUR_TOKEN"
Run the test suite:
composer test
# or
php artisan testapp/
βββ Events/ # Event classes (TaskCreatedEvent, TaskUpdatedEvent)
βββ Http/
β βββ Controllers/ # API controllers
β βββ Requests/ # Form request validation
β βββ Resources/ # API resources
βββ Listeners/ # Event listeners for emails
βββ Mail/ # Mailable classes
βββ Models/ # Eloquent models
βββ Policies/ # Authorization policies
database/
βββ factories/ # Model factories
βββ migrations/ # Database migrations
βββ seeders/ # Database seeders
resources/
βββ views/
βββ mail/ # Email templates (Blade)
routes/
βββ api.php # API routes
For email notifications to work properly, configure your queue driver in .env:
QUEUE_CONNECTION=database
Then run migrations to create the jobs table:
php artisan migrateLaravel Telescope is included for debugging. Access it at /telescope (in development mode).
- All timestamps are in UTC
- Passwords are hashed using bcrypt
- API tokens are generated using Laravel Sanctum
- Email notifications are queued for better performance
- Task status values: The API accepts
pending,in_progress,completed, but the database migration usesdoneinstead ofcompleted. This inconsistency should be resolved in a future update.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Mostafa Alaa Mohamed