How ckent-sim/gofilm works
Project Type & Purpose
• GoFilm is a full-stack online streaming platform. The project is divided into three major parts:
• The client folder contains the Vue-based frontend.
• The server (and film/server) directories hold the backend business logic implemented using Gin.
• The film folder also includes deployment configurations (Dockerfile, docker-compose.yml, nginx configurations, Redis config) used to manage production infrastructure.
• The README highlights two primary interfaces: the public-facing website and an administrative backend for managing film resources, data collection, and scheduled updates.
Analyzing the File Structure
• The top-level directories (client, film, server) indicate a separation of concerns:
• “client”: Contains everything related to the Vue SPA. With files organized into assets, components, views, and routing, this clearly encapsulates the presentation/UI layer.
• “server” and “film/server”: Both contain controllers, logic, models, plugins, and routers. There are two similar backend directories, which suggests one may be dedicated to a certain deployment or evolution of the backend service.
• “film”: In addition to backend code under film/server, it includes data and configuration for nginx (acting as a reverse proxy/static file server) and Redis (used for caching) as well as Docker-related files. This indicates the deployment flow and container orchestration strategy.
• Configuration files like docker-compose.yml, Dockerfile, and nginx.conf indicate containerized deployment and a structured production stack.
a. Main Components:
• Frontend Client:
• Vue SPA (built with Vite, using ElementPlus) which handles the user-facing interface.
• Backend Services:
• API Service(s): Based on Gin providing RESTful endpoints for both public site and admin sections.
• Two backend directories (“server” and “film/server”) can be represented as a unified backend service or as separate services if they serve different stages (e.g., development vs. production deployment).
• Controllers, Logic layers, and Models are separate but collaborate closely.
• Infrastructure & Deployment:
• Nginx: Reverse proxy and static resource server as configured under film/data/nginx.
• Scheduling/Resource Crawler: Use of robfig/cron (for scheduled tasks like film updates) and gocolly for resource/spider tasks. Represent these as background worker components.
• Data storage & Cache: Indicate the use of a database (likely MySQL or similar via GORM) and a Redis instance used for caching.
• External Systems:
• Integration points may be shown where appropriate (e.g., external film sources or third-party API calls used by the spider).
b. Relationships & Interactions:
• The client communicates with the backend via API endpoints (HTTP calls).
• The backend service communicates with the database and Redis.
• The cron/spider components operate within or as part of the backend, periodically updating film data.
• Nginx serves both as a gateway for static assets (from the client build) and as a reverse proxy, directing API calls to the backend servers.
• Docker-compose indicates container-based orchestration, so these components could be shown as containerized modules.
c. Architectural Patterns and Design Principles:
• Separation of Concerns: Clearly separate frontend presentation (client) from backend API logic.
• Modularization: Use of controllers, logic, models, and plugins in the backend layers allowing for flexibility and testability.
• Use of Middleware: The backend employs middleware for CORS handling and JWT authentication.
• Microservice-like structure: Although not fully split into independent microservices, the separation of film/server and server/ might indicate evolution towards service separation or an environment split (development vs production).
d. Relevant Technologies, Frameworks, Libraries:
• Frontend: Vue, Vite, ElementPlus.
• Backend: Go with Gin, GORM for ORM, go-redis for caching, gocolly for web scraping, and robfig/cron for scheduling.
• Deployment: Docker, docker-compose, nginx.
• Additional libraries are visible within the project’s plugins (e.g., handling file management and request utilities).