How whhsky/covid-19-ksh works
Project Type and Purpose
• The project is a Django-based web application that provides real-time COVID-19 epidemic data visualizations. It combines traditional Django views with a crawler (爬虫) component and incorporates pyecharts for dynamic charting.
• Key components include a web frontend (templates, static assets), backend logic (Django apps for processing, views, models, and serializers), asynchronous task handling (CeleryTask), and a data crawling module (pachong.py under the “demo” app).
Analyzing the File Structure
• Top-Level Directories:
• The “keshihua” directory is the main Django project folder, containing configuration files (settings.py, urls.py, wsgi.py) as well as the project-level celery setup (celery.py).
• “CeleryTask” is a Django app that handles background tasks, most likely using Celery to offload heavy or scheduled work.
• “demo” is another Django app which appears to be the core of the COVID data display, with modules for handling CSV files, data serializing, and even a crawler (pachong.py) for data gathering.
• “static” and “templates” are used for the frontend—HTML files, CSS, JavaScript, and even video files to support the visual experience.
• “manage.py” and “requirements.txt” signal the standard Django project structure.
• Notable Files:
• Data files under “demo/csv” and “demo/data” imply that the system processes and possibly stores epidemic-related data (both in CSV and JSON formats).
• The presence of “pachong.py” in the “demo” app shows that there is functionality to scrape or update external data.
• Web Client (Browser):
• Sends HTTP requests to the Django server.
• Receives HTML pages rendered from templates and interacts with dynamic JavaScript (from the static directory) for interactive data visualizations.
• Django Web Server & Core Application (keshihua and demo):
• Central business logic handled within the “demo” app. This part handles routing (via “demo/urls.py”), views (“demo/views.py”), and data models (“demo/models.py”).
• Data visualization via pyecharts likely happens within the views or utility functions.
• The crawler (pachong.py) is part of the demo app, which periodically gathers data from external sources.
• Asynchronous Task Processing (CeleryTask):
• This app contains Celery tasks (notice task.py) and configurations to handle asynchronous operations like data crawling, data processing, and any scheduled updates.
• It interacts with the Django ORM (models) or external APIs to run these tasks without affecting user response times.
• Data Storage:
• While no explicit database type is mentioned, Django migrations exist under both “CeleryTask/migrations” and “demo/migrations” indicating relational DB use for storing epidemic data and task states.
• External Services / Data Sources:
• The crawler in “demo/pachong.py” and the CSV/JSON data files show that external data is acquired and brought into the system.
• There might be scheduled tasks launched by Celery to keep the dataset updated.
Technology Stack Indicators
• Python 3.6 as specified in the README.
• Django framework for the web application.
• Celery for task scheduling (as indicated by the “CeleryTask” and “celery.py” configuration).
• pyecharts for data visualization.
• CSV and JSON for data input formats.
• Use clear labels for every component (e.g., “Django (Core – demo & keshihua)”, “CeleryTask Worker”, “Database”, “Web Client”).
• Frontend components (Templates, Static Files)
• Backend components (Django apps, Celery tasks)
• External data sources and asynchronous task flow.