How tencentblueking/bk-audit works
Main Components
• Frontend Application – Represented by the src/frontend directory. Note that it includes a complete Vue.js SPA (with components, views, router, hooks, etc.), static assets, and build configurations (Dockerfile, package.json).
• Backend Application – Housed in the src/backend directory. This is a Django application that is divided into various submodules:
– API Layer: Under “src/backend/api”, there are multiple API endpoints (for audit, bk_iam, bk_log, bk_monitor, etc.) that interface with different system functions.
– Modular Apps: The “src/backend/apps” directory contains many domain-specific modules (audit, feature, itsm, meta, notice, permission, sops, user_manage, etc.). Each module encapsulates business logic for its respective area.
– Core Components & Utilities: Located in “src/backend/core” and “src/backend/config”, these handle caching, logging, middleware, SQL building, utilities, and environment configurations.
– Third-Party Integrations: The “src/backend/blueking” directory shows integration with BlueKing specific functionality like components and API calls.
• Infrastructure & Deployment: Dockerfiles for both backend and frontend are provided along with configuration files like .djangoignore, .flake8, and CI/CD workflows (under .github/workflows), indicating containerized deployment and automated tests.
• Data Stores and External Systems (Implicit): Although not directly visible in the file tree, components for caching (in “core/cache”), logging, message queuing (e.g., Kafka in “src/backend/core/kafka”), and integrations with BlueKing IAM and other systems suggest connections to databases, Redis/Memcache, message brokers, etc.
Relationships and Interactions
• Modular Backend Interactions: Within the backend layer, illustrate how the API endpoints interact with specific apps (audit, permission, meta, etc.). Show how the “core” utilities (logging, cache, middleware) are used by these modules.
• Services Communication: Show how the separate “services” (puller, web) interact with the core backend and database components. For instance, the puller service might fetch or process audit logs, while the web service likely handles user-facing audit visualizations and results.
Architectural Patterns and Design Principles
• Layered Architecture: Clearly differentiate between the client layer (frontend), application layer (backend APIs, modular applications, and services), and infrastructure/data stores.
• Modularization: Highlight that the backend is highly modular (with separate apps for different domains such as audit, permission, meta, and notice) and may follow principles akin to a microservices/microkernel architecture even though it may be deployed as a monolithic Django app.
• Extensibility and Integration: The system is designed to integrate with other BlueKing projects (e.g., BK-CMDB, BK-CI, BK-PaaS) so mark clear extension points and integration channels.
Technologies and Frameworks
• Backend: Django (Python), with Docker-based deployment, use of middleware, custom SQL builders, and other utility libraries present in “core” and “config”.
• Frontend: Likely a Vue.js SPA (using .vue files, TypeScript, ESLint, and Vite for bundling) with modern JavaScript tooling.
• DevOps: CI/CD is managed with GitHub Actions workflows, and the project includes pre-commit hooks and configuration files for linting and style guidelines.
• External: Although not explicitly listed in the file tree, integration with Kafka, Redis, and BlueKing microservices are inferred from the folder names and external documentation links.