How lybbn/django-vue-lyadmin works
Project Components
• Backend: A Django application managing business logic, authentication (using JWT via drf-simplejwt), and a set of well‐organized Django “apps” (e.g., address, logins, lymessages, mall, oauth, etc.). It integrates Celery tasks, web socket communications (via channels), and RESTful APIs.
• Frontend: A Vue-based interface implemented in two versions – one based on webpack (the “frontend” directory) and one using Vite (“frontend_vite”). These provide the user interface for the admin dashboard, low-code form and CRUD generation as well as various interactive pages.
• Third-Party Services & Integrations: The system integrates with external payment gateways (e.g., Alipay, WeChat, and more), SMS providers, and possibly other external APIs.
• Supporting Infrastructure: Docker-compose is used to deploy containers for the Django server, MySQL, Redis, and Nginx. Static file serving and deployment orchestration are also covered.
File Structure for Architectural Cues
• The backend folder contains:
• A main Django project (application) with configuration files including asgi.py, wsgi.py, settings.py, which indicate support for both synchronous and asynchronous workflows.
• An “apps” folder that segments various functional modules such as “lyusers”, “lymonitor”, “mall”, “oauth”, etc. This modular structure suggests a clean separation of concerns.
• Utility modules and extra apps (e.g., an Alipay SDK), migration scripts, and management commands.
• Celery integration (celery.py in the application folder) and periodic task definitions.
• The frontend and frontend_vite directories contain a modern Vue3 project with components, views, API configurations, and asset management. They use standard Vue ecosystem libraries like elementplus.
• Docker-related files (docker-compose.yml, docker_env) denote a containerized deployment with individual services (MySQL, Redis, Django, nginx).
a. Main Components:
• Frontend Client(s): Represented by both the traditional Vue project and the Vite variant.
• API Gateway / Backend Server: Django server exposing REST APIs and serving web socket endpoints, handling authentication, business logic, and admin functionalities.
• Task Scheduler: A dedicated Celery worker (and beat scheduler) handling asynchronous tasks and periodic jobs.
• Database: MySQL (with designated migrations and SQL scripts) that stores user data, system configurations, and transactional records.
• Cache & Message Queue: Redis is used for caching and possibly as a broker (for Celery) or session storage.
• Web Server / Reverse Proxy: Nginx (as configured in the Docker environment) handling static file serving, SSL termination, and proxying requests to the backend.
• External Services: Represent integrations like payment gateways (Alipay, WeChat), SMS services, and third-party APIs.
b. Relationships and Data Flow:
• Celery Workers (Task Scheduler) are triggered by the Backend to execute asynchronous or scheduled tasks and may also write results back to the Database.
• The Nginx component functions as a reverse proxy routing external client requests to the appropriate internal service (static frontend files, Django API, and web socket endpoints).
• Interactions with External Services (e.g., Payment, SMS, etc.) should be illustrated as outbound connections from the Backend.
c. Architectural Patterns & Design Principles:
• Modular Architecture: Break down the backend into multiple Django apps, each with a clear purpose.
• Separation of Concerns: Distinct separation between frontend (presentation) and backend (business logic & APIs).
• Asynchronous Processing: Use of Celery for background task processing, indicating separation between synchronous request/response flows and background job processing.
• Containerization: Docker-compose deployment demonstrates separation of infrastructure (database, cache, web server) into individual isolated services.
• Security and Authentication: Use of JWT for authentication and permissions control.
d. Relevant Technologies:
• Frontend: Vue 3, ElementPlus, Tinymce, Vite/Webpack.
• Backend: Python, Django, Django REST Framework (drf), Celery, Channels.
• Infrastructure: MySQL, Redis, Nginx, Docker/Docker Compose.
• Additional libraries: Payment SDKs, SMS utilities, and other integration utilities.