# LOCAL PULSE

Australia's Local News Platform - A Laravel 11-based news platform delivering hyper-local coverage across Australia.

## Features

- **Public Frontend**: Homepage, latest news, breaking news, category pages, location-based news, event listings, weather, traffic, and community stories
- **Admin Dashboard**: Full content management system for editors, journalists, and moderators
- **User Accounts**: Registration, login, saved articles, and profile management
- **Comments**: Moderated comment system on articles
- **Newsletter**: Email subscription system
- **SEO**: Meta tags, Open Graph, Twitter Cards, Schema.org JSON-LD, XML sitemap, RSS feeds
- **API**: RESTful API v1 for articles, categories, locations, events, breaking news, and search
- **News Importer**: One-click import of licensed news from NewsAPI.org (with auto image download)

## Tech Stack

- **Backend**: Laravel 11 (PHP 8.2+)
- **Frontend**: Blade templates, Tailwind CSS 3, Alpine.js
- **Database**: MySQL
- **Build**: Vite

## Requirements

- PHP 8.2 or higher
- Composer 2.x
- Node.js 18+ and npm
- MySQL 8.0+
- Laragon (recommended for Windows)

## Installation

1. Clone the repository:
```bash
git clone <repository-url> localpulse
cd localpulse
```

2. Install PHP dependencies:
```bash
composer install
```

3. Install Node.js dependencies:
```bash
npm install
```

4. Copy environment file:
```bash
cp .env.example .env
```

5. Generate application key:
```bash
php artisan key:generate
```

6. Configure database in `.env`:
```env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=localpulse
DB_USERNAME=root
DB_PASSWORD=
```

7. Run migrations and seeders:
```bash
php artisan migrate:fresh --seed
```

8. Build frontend assets:
```bash
npm run build
```

9. Serve the application:
```bash
php artisan serve
```

Visit `http://localhost:8000` in your browser.

## Demo Accounts

| Role | Email | Password |
|------|-------|----------|
| Admin | admin@localpulse.com | password |
| Editor | editor@localpulse.com | password |
| Journalist | journalist@localpulse.com | password |
| Moderator | moderator@localpulse.com | password |
| User | user@localpulse.com | password |

## Artisan Commands

```bash
# Generate XML sitemap
php artisan sitemap:generate

# Generate RSS feeds
php artisan rss:generate

# Import news from NewsAPI.org
php artisan news:import --mode=latest --limit=30                    # top AU headlines
php artisan news:import --query="AFL" --from=2026-08-20 --to=2026-09-02 --limit=20
php artisan news:import --query="housing" --from=2026-08-15 --to=2026-09-02 --no-images
php artisan news:import --query="Sydney" --from=2026-08-20 --to=2026-09-02 --limit=30 --dry-run

# Run scheduled tasks
php artisan schedule:run

# Run tests
php artisan test
```

## News Importer

LOCAL PULSE can pull licensed news from [NewsAPI.org](https://newsapi.org/) (free dev tier, 100 req/day). Add your key to `.env`:

```env
NEWSAPI_KEY=your-key-here
NEWSAPI_AU_SOURCES=abc-news-au,news-com-au,australian-financial-review,google-news-au
```

Then visit **Admin → News Importer** to run a one-click import. The importer:

- Fetches articles from your chosen sources / date range
- Downloads and stores images locally to `storage/app/public/news-imports/`
- Auto-tags articles based on AU keywords (Sydney, AFL, RBA, etc.)
- Skips duplicates and `[Removed]` placeholders
- Adds a "Read full article at source →" attribution link to comply with copyright

**Free-tier limit:** `/everything` is restricted to the last ~30 days. For historical data (e.g. July onwards), upgrade to a paid plan or use multiple scheduled daily imports.

**Copyright:** Imported content is summary + attribution only, not full text reproduction. Always verify your plan's ToS before going live.

## Scheduled Tasks

The application includes scheduled tasks configured in `app/Console/Kernel.php`:
- Daily sitemap generation
- Daily RSS feed generation
- Publish scheduled articles (every 5 minutes)
- Expire breaking alerts
- Process analytics (hourly)

## API Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/v1/articles` | List published articles |
| GET | `/api/v1/articles/{slug}` | Get single article |
| GET | `/api/v1/categories` | List categories |
| GET | `/api/v1/locations` | List locations |
| GET | `/api/v1/events` | List upcoming events |
| GET | `/api/v1/breaking` | List breaking news |
| GET | `/api/v1/search?q=` | Search articles |
| POST | `/api/v1/analytics/page-view/{slug}` | Track page view |
| GET | `/api/v1/analytics/trending` | Get trending articles |

## Project Structure

```
app/
├── Console/Commands/       # Artisan commands
├── Http/
│   ├── Controllers/        # Public and admin controllers
│   ├── Middleware/          # HTTP middleware
│   └── Resources/           # API resources
├── Models/                  # Eloquent models
├── Providers/               # Service providers
└── View/Components/         # Blade components

database/
├── factories/               # Model factories
├── migrations/              # Database migrations
└── seeders/                 # Database seeders

resources/
├── css/app.css              # Tailwind CSS + custom styles
├── js/app.js                # JavaScript (Alpine.js)
├── views/                   # Blade templates
│   ├── components/          # Reusable Blade components
│   ├── layouts/             # Page layouts
│   ├── admin/               # Admin panel views
│   └── *.blade.php          # Public page views
└── feeds/                   # RSS feed views

routes/
├── web.php                  # Web routes
├── api.php                  # API routes
└── auth.php                 # Authentication routes
```

## Content Categories

- Local News
- Crime & Courts
- Traffic & Transport
- Community
- Sport
- Business
- Lifestyle
- Food & Dining
- Politics
- Health
- Education
- Environment
- Technology
- Entertainment
- Weather
- Opinion
- Investigations

## Supported Locations

- Victoria (Melbourne, Geelong, Ballarat, Bendigo, etc.)
- New South Wales (Sydney, Newcastle, Wollongong, etc.)
- Queensland (Brisbane, Gold Coast, Sunshine Coast, etc.)
- Western Australia (Perth, Fremantle, Bunbury, etc.)
- South Australia (Adelaide, Mount Gambier, etc.)
- Tasmania (Hobart, Launceston, Devonport, etc.)

## License

MIT License

## Support

For issues or questions, please open an issue on GitHub or contact news@localpulse.com.
