An open API service indexing awesome lists of open source software.

https://github.com/kinchan-code/discussion-platform-api


https://github.com/kinchan-code/discussion-platform-api

laravel12 mysql typesense

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

          

# Community-Powered Protocol & Discussion Platform API

A robust Laravel REST API for a community-driven platform where users can share wellness protocols, create discussion threads, and engage through comments, reviews, and voting.

## πŸš€ Features

- **Protocols**: Structured wellness instructions with tags, ratings, and author attribution
- **Threads & Comments**: Discussion topics with multi-level nested replies
- **Reviews & Voting**: Star ratings, feedback, and upvote/downvote system (one vote per user)
- **User Profiles**: Statistics and activity tracking
- **Search**: Full-text, faceted search with Typesense Cloud & Laravel Scout
- **Authentication**: Laravel Sanctum token-based authentication
- **Clean Architecture**: Service layer, DTOs, and standardized API responses

## πŸ—οΈ Tech Stack

- **Framework**: Laravel 12.x (PHP 8.2+)
- **Database**: MySQL 8.0+
- **Search**: Typesense Cloud via Laravel Scout
- **Auth**: Laravel Sanctum
- **Testing**: PHPUnit

## ⚑ Quick Start

1. **Clone & Install**

```bash
git clone
cd discussion-platform-api
composer install
npm install
```

2. **Environment Setup**

```bash
cp .env.example .env
php artisan key:generate
# Edit .env for DB and Typesense credentials
```

3. **Database & Seed**

```bash
php artisan migrate
php artisan db:seed
```

4. **(Optional) Search Index**

```bash
php artisan scout:import "App\\Models\\Protocol"
php artisan scout:import "App\\Models\\Thread"
```

5. **Run Server**
```bash
php artisan serve
# API at http://localhost:8000
```

## πŸ“š API Overview

**Authentication**

- `POST /api/register` β€” Register new user
- `POST /api/login` β€” Login user
- `POST /api/logout` β€” Logout user (auth required)
- `GET /api/me` β€” Get current user (auth required)

**Profile**

- `GET /api/profile` β€” Get current user profile (auth required)
- `PUT /api/profile` β€” Update profile (auth required)
- `GET /api/profile/statistics` β€” User activity stats (auth required)
- `GET /api/profile/replies` β€” User’s replies (auth required)
- `GET /api/profile/comments` β€” User’s comments (auth required)
- `GET /api/profile/reviews` β€” User’s reviews (auth required)

**Protocols**

- `GET /api/protocols` β€” List protocols (filter/sort supported)
- `GET /api/protocols/featured` β€” Featured protocols
- `GET /api/protocols/filters` β€” Protocol filters
- `GET /api/protocols/{id}` β€” Get protocol
- `GET /api/protocols/{id}/stats` β€” Protocol stats
- `POST /api/protocols` β€” Create protocol (auth required)
- `PUT /api/protocols/{id}` β€” Update protocol (auth required)
- `DELETE /api/protocols/{id}` β€” Delete protocol (auth required)

**Threads**

- `GET /api/threads` β€” List threads (filter/sort supported)
- `GET /api/threads/trending` β€” Trending threads
- `GET /api/threads/{id}` β€” Get thread
- `GET /api/threads/{id}/stats` β€” Thread stats
- `GET /api/protocols/{protocol}/threads` β€” Threads by protocol
- `POST /api/threads` β€” Create thread (auth required)
- `PUT /api/threads/{id}` β€” Update thread (auth required)
- `DELETE /api/threads/{id}` β€” Delete thread (auth required)

**Comments**

- `GET /api/threads/{thread}/comments` β€” Get thread comments
- `GET /api/comments/{comment}/replies` β€” Get comment replies
- `GET /api/replies/{reply}/nested` β€” Get nested replies
- `POST /api/threads/{thread}/comments` β€” Create comment (auth required)
- `POST /api/comments/{comment}/reply` β€” Reply to comment (auth required)
- `POST /api/replies/{reply}/reply` β€” Reply to reply (auth required)
- `PUT /api/comments/{comment}` β€” Update comment (auth required)
- `DELETE /api/comments/{comment}` β€” Delete comment (auth required)

**Reviews**

- `GET /api/protocols/{protocol}/reviews` β€” Get protocol reviews
- `POST /api/protocols/{protocol}/reviews` β€” Create review (auth required)
- `DELETE /api/reviews/{id}` β€” Delete review (auth required)

**Voting**

- `POST /api/threads/{thread}/vote` β€” Vote on thread (auth required)
- `POST /api/comments/{comment}/vote` β€” Vote on comment (auth required)
- `POST /api/reviews/{review}/vote` β€” Vote on review (auth required)

**Tags & Analytics**

- `GET /api/tags/popular` β€” Popular tags
- `GET /api/stats/dashboard` β€” Platform statistics

---

All endpoints return standardized JSON. Most write actions require authentication (Bearer token).

## πŸ§ͺ Testing

```bash
php artisan test
```

**For questions or feedback, feel free to reach out.**