PIMS/app/Modules/Movies/README.md

61 lines
2.3 KiB
Markdown
Raw Normal View History

2025-12-07 03:49:26 +00:00
# Movies Module
This module implements service-first Movies functionality, including:
- Admin search + accept flow (OMDb)
- Public browsing (Inertia pages) backed by JSON API
- Strict controller→service separation
## Endpoints
Admin (auth required)
- GET /admin/movies → Inertia admin page (search + accept)
- GET /admin/movies/search?q=&page= → JSON results from OMDb (10 per page)
- GET /admin/movies/exists?provider_id= → Duplicate check
- POST /admin/movies/accept { provider_id, mode: overwrite|duplicate } → Persist movie
Public
- Inertia pages: GET /movies, GET /movies/{id}
- JSON API: GET /api/movies, GET /api/movies/{id}
## Data model
- Fully normalized tables: movies, genres, actors, directors, studios, countries, languages + pivot tables.
- Provider ID is not unique. Duplicates are allowed when “Save as Duplicate” is selected.
- Images are stored as remote URLs only (not downloaded).
## Services & Contracts
- Provider: App\\Modules\\Movies\\Services\\Contracts\\MovieProvider (OMDb implementation)
- Browse: ListMoviesServiceInterface, ShowMovieServiceInterface
- Admin: UpsertMovieServiceInterface, CheckMovieExistsServiceInterface
All DI bindings are registered in MoviesServiceProvider.
## Admin flow
1. Search calls /admin/movies/search (OMDb search). List shows poster, title, year only (no details calls).
2. Accept button:
- If unique, accepts immediately (no modal).
- If duplicate exists by provider_id, shows modal: Overwrite | Save as Duplicate | Cancel.
3. On successful accept, a small toast appears and the row is marked “Accepted”.
## Public browsing
- /movies (Inertia) fetches from /api/movies with infinite scroll. Each row shows poster, title, year, rating, genres, and a ~50-word description snippet.
- /movies/{id} (Inertia) fetches from /api/movies/{id} and shows details with all relations.
## Environment
Add to .env (values shown as placeholders):
```
OMDB_API_KEY=
OMDB_LANGUAGE=en-US
OMDB_CACHE_TTL=3600
```
Set your real OMDb key locally (per user decision). Timezone is America/Chicago.
## Development
- Run backend: `php artisan serve`
- Frontend dev: `npm install && npm run dev`
- Tests: `./vendor/bin/pest`
## Notes
- Pagination: OMDb search uses 10/page; public DB pagination defaults to 20/page (configurable at request).
- Controller classes contain no business logic; all logic resides in services.