All skills

Learningvideos

current

Learningvideos is a Django and Django REST Framework service for managing and serving Merchmix Learning Center video content. It provides authenticated CRUD APIs for learning videos, category and text filtering, thumbnail fallback generation for YouTube videos, a Django admin interface, and a public health endpoint. The service stores video metadata and uploaded thumbnails in PostgreSQL-backed Django models and is deployed as a containerized web application.

main·1b36a73dd16b·generated by gpt-5.6-luna·9/4/2026, 1:19:10 PM View as Markdown

This service gives Merchmix users a Learning Center where they can find short training videos about merchandise planning topics such as Allocation, WSSI, Replenishment, and Analytics. Staff can create, update, search, categorize, and remove learning videos, while users can retrieve the content and its thumbnail for display in the learning experience.

5
Learning Content ManagementproductionwriteOtheruser facingagent facing99%

Maintain the training videos available in the Merchmix Learning Center, including their titles, descriptions, video links, durations, categories, thumbnails, and publication metadata.

The LearningVideoViewSet is a Django REST Framework ModelViewSet registered at /api/learning/videos/, providing list, retrieve, create, update, partial update, and destroy operations. Django admin also exposes LearningVideo management with category and date filtering plus title and description search.

Learning Content DiscoveryproductionreadReportinguser facingagent facing99%

Allow Merchmix users to browse training videos and narrow results by merchandise-planning category or by words in the title and description.

GET /api/learning/videos/ returns LearningVideo records ordered by updated_at descending. Optional category filtering uses an exact category match; search performs case-insensitive title or description matching.

Learning Video PresentationproductionreadOtheruser facing98%

Provide the information needed for the Learning Center to display a video card, including a usable thumbnail, duration, category, view count, and publication date.

LearningVideoSerializer maps database fields to the API contract, including videoUrl and publishedDate. It returns an uploaded thumbnail when the stored file exists, otherwise derives an hqdefault YouTube thumbnail URL for supported YouTube URL formats.

Service Health MonitoringproductionreadOtheragent facinginternal92%

Let deployment and monitoring systems confirm that the Learning Video API is running.

The unauthenticated GET /api/learning/health/ endpoint returns a JSON success status and a running-message. The root /health/ route is also included through the API URL configuration.

Learning Center AuthorizationpartialexecuteAuthenticationuser facinginternal90%

Restrict Learning Center content operations to tenants and users who are entitled to the learning service and have the required action permission.

Protected DRF operations use MerchMixAuthentication and LearningCenterAccessPermission. The permission policy checks the learning service entitlement and maps list/retrieve to learning:read, create to learning:create, update operations to learning:update, and deletion to learning:delete.

3
Browse and filter learning videos

A Learning Center client retrieves available training videos and optionally filters them for a category or search term.

  1. 1.Send an authenticated GET request to /api/learning/videos/.
  2. 2.Optionally provide category and/or search query parameters.
  3. 3.The service queries LearningVideo records ordered by most recently updated.
  4. 4.The serializer returns video metadata, API-friendly field names, and an uploaded or derived thumbnail URL.
Create or maintain learning content

An authorized content administrator maintains the Learning Center catalogue.

  1. 1.Authenticate through the MerchMix authorization context.
  2. 2.Submit create, update, partial update, or delete requests to /api/learning/videos/.
  3. 3.The permission layer checks the learning service entitlement and action-specific permission.
  4. 4.Django REST Framework validates and persists the LearningVideo record and any thumbnail upload.
Resolve a video thumbnail

The API ensures a video card has a usable poster image where possible.

  1. 1.Check whether the LearningVideo has an uploaded thumbnail.
  2. 2.Verify that the referenced stored file still exists.
  3. 3.Return an absolute media URL when the upload exists.
  4. 4.Otherwise extract an 11-character YouTube video ID and return the YouTube hqdefault thumbnail URL; return an empty value for unsupported URLs.

A conventional Django monolith exposes server-rendered administration and REST API endpoints around a single LearningVideo domain model. Authentication is implemented as a custom DRF authentication class that forwards bearer-token context validation to the MerchMix Auth Service, while deployment runs the WSGI application behind Gunicorn in a container.

Components
learningvideo Django application and LearningConfig app registrationLearningVideo Django ORM model and initial migrationLearningVideoViewSet and LearningVideoSerializer REST API layerCustom MerchMix authentication and Learning Center permission policyDjango admin LearningVideo management interfaceDjango media serving for uploaded thumbnailsDatabase startup guard enforcing environment-specific PostgreSQL database allowlistsGunicorn container runtime and Azure/GCP deployment configuration
Patterns
Django MVC-style application structureDjango REST Framework ModelViewSet with router-generated CRUD routesSerializer field mapping from snake_case model fields to frontend camelCase fieldsService-backed authorization context and permission mappingEnvironment-driven configuration with fail-closed database-name validationFallback external thumbnail generation for YouTube URLs
9
KindIdentifierDescription
httpGET /api/learning/health/Public health endpoint returning a JSON success response.
httpGET /api/learning/videos/List learning videos, optionally filtered with category and search query parameters.
httpPOST /api/learning/videos/Create a learning video, subject to authorization and serializer/model validation.
httpGET /api/learning/videos/{id}/Retrieve one learning video.
httpPUT /api/learning/videos/{id}/Replace one learning video.
httpPATCH /api/learning/videos/{id}/Partially update one learning video.
httpDELETE /api/learning/videos/{id}/Delete one learning video.
httpGET /admin/Django admin interface for managing LearningVideo records.
httpGET /media/{path}Serve uploaded media files, including learning video thumbnails, through Django.
1
RouteNamePurpose
/admin/Learning Video AdminAdministrative interface for listing, searching, filtering, and editing learning video records.
3
EntityOwnershipDescription
LearningVideoownsLearning content metadata: title, description, video URL, optional thumbnail, duration, category, view count, publication date, and update timestamp.
Learning video thumbnail filesownsOptional uploaded image files stored under learning/thumbnails/ and served through the configured media path.
Authorization contextreadsUser, tenant, entitlement, role, group, and permission context supplied by the MerchMix Auth Service for protected API requests.
9
NameKindRelationshipCriticality
PostgreSQLdatabasereadscritical
Django ORM and migration systemlibraryusescritical
MerchMix Auth Serviceinternal servicecallsrequired
merchmix_authliblibraryusesrequired
YouTube thumbnail serviceexternal servicereadsoptional
Redisdatabasedepends_onsupporting
NATSqueuedepends_onsupporting
Django REST Frameworklibraryusescritical
Pillowlibraryusesrequired
Python 3.12 runtimeDjango 6.0.6Django REST Framework 3.17.1PostgreSQL via psycopg2-binaryGunicornPyJWT and cryptographydjango-cors-headersWhiteNoisePillowDockerAzure Container Apps and Google Cloud Run deployment configurations
6
  • The supplied source shows a commented-out increment_view action, so view-count tracking is not currently exposed as an API operation; the views field exists but the evidence does not show it being updated.
  • The merchmix_authlib package is conditionally imported and comments state that deployments without it allow authentication and permission checks to become no-ops; authorization enforcement therefore depends on the runtime package being available.
  • No frontend implementation is present in this repository; the Learning Center user interface is inferred only from serializer naming and thumbnail comments.
  • The scanner reports Redis and NATS signals, but the supplied source does not establish how this service uses them or whether they are runtime dependencies.
  • Uploaded media is served from the application filesystem, which deployment comments identify as ephemeral; there is no demonstrated blob-storage integration.
  • No evidence establishes video hosting, playback, analytics, recommendation, progress tracking, or course/lesson relationships beyond the LearningVideo record.

Use this repository for Learning Center video catalogue operations and training-content retrieval, not for merchandise planning calculations or video playback analytics.

  • For browsing content, call GET /api/learning/videos/ and use category or search query parameters when appropriate.
  • For a single item, use /api/learning/videos/{id}/; expect videoUrl, publishedDate, and thumbnail in the response.
  • Treat POST, PUT, PATCH, and DELETE as authorization-protected content-management operations requiring the corresponding learning service permission.
  • Do not assume the views field is current or incrementable through the API; the increment_view endpoint is commented out.
  • Health checks may call /api/learning/health/ without authentication.
  • When troubleshooting authorization, verify the bearer token, X-Tenant-Client-Id header, Auth Service context endpoint, learning service entitlement, and action-specific permission.
  • Do not assume Redis or NATS behavior without inspecting additional source or deployment configuration.
  • Uploaded thumbnail URLs may fail if the underlying container file is absent; the serializer attempts a YouTube fallback for YouTube video URLs.