# tencent/codeanalysis architecture

> Architecture diagram of the GitHub repository tencent/codeanalysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tencent/codeanalysis
- Repository: https://github.com/tencent/codeanalysis

## Overview

##### Project type and purpose
- This is a full-stack, microservice-based code analysis and issue-tracking platform (“Tencent Cloud Code Analysis” a.k.a. CodeDog).
- It comprises three logical slices:
- Client (CLI and IDE/Jenkins plugins)
- Server (a collection of Django microservices + Celery workers)
- Web (micro-frontend React apps managed by Lerna)
- Purpose: orchestrate code-analysis tasks (linting, metrics, security) via REST APIs, asynchronous workers, and present results in web UIs or IDE/CI integrations.

##### File structure
Top level:
- client/ – Python CLI and local-node runner modules
- plugins/ – Jenkins and JetBrains IDE plugins for CI/editor integration
- server/projects/ – multiple Django services:
- analysis/ – code analysis API + Celery tasks
- main/ – core APIs (projects, repos, jobs, users, scan_conf, nodemgr)
- login/ – authentication service
- file/ – file-management service (uploads/downloads)
- scmproxy/ – proxy to external Git/GitHub/GitLab
- web/ – Lerna monorepo of React micro-frontends:
- login, tca-layout, tca-manage (admin), tca-analysis (results), shared, framework, etc.
- helm-charts/ + docker-compose.yml – Kubernetes and Docker deployment descriptors
- Scripts and Dockerfiles for local/docker deployment

##### Supplementary insights from README
- Emphasis on integration points (APIs, DevOps, external SCM, dynamic tool loading)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Tier
    subgraph "Client Tier"
        Browser["Browser"]:::external
        CLI["CLI Client"]:::external
        Jenkins["Jenkins Plugin"]:::external
        IDE["IDE Plugin"]:::external
    end

    click CLI "https://github.com/tencent/codeanalysis/tree/main/client/"
    click Jenkins "https://github.com/tencent/codeanalysis/tree/main/plugins/jenkins_plugin/"
    click IDE "https://github.com/tencent/codeanalysis/tree/main/plugins/jetbrains_plugin/"

    %% Web UI Micro-frontends
    subgraph "Web UI Micro-frontends"
        LoginUI["Login App"]:::frontend
        Framework["Framework"]:::frontend
        Layout["TCA Layout"]:::frontend
        Manage["TCA Manage"]:::frontend
        AnalysisUI["TCA Analysis"]:::frontend
        Shared["Shared Components"]:::frontend
        Webpack["Webpack Utilities"]:::frontend
    end

    click LoginUI "https://github.com/tencent/codeanalysis/tree/main/web/packages/login/"
    click Framework "https://github.com/tencent/codeanalysis/tree/main/web/packages/framework/"
    click Layout "https://github.com/tencent/codeanalysis/tree/main/web/packages/tca-layout/"
    click Manage "https://github.com/tencent/codeanalysis/tree/main/web/packages/tca-manage/"
    click AnalysisUI "https://github.com/tencent/codeanalysis/tree/main/web/packages/tca-analysis/"
    click Shared "https://github.com/tencent/codeanalysis/tree/main/web/packages/shared/"
    click Webpack "https://github.com/tencent/codeanalysis/tree/main/web/packages/webpack/"

    %% API Gateway
    APIGateway["API Gateway / Nginx"]:::service

    %% Application Tier
    subgraph "Application Tier"
        LoginSvc["Login Service"]:::service
        MainSvc["Main Service"]:::service
        AnalysisSvc["Analysis Service"]:::service
        FileSvc["File Service"]:::service
        SCMProxy["SCM Proxy Service"]:::service
        CeleryBroker["Celery Broker"]:::queue
        CeleryWorkers["Celery Workers"]:::worker
    end

    click LoginSvc "https://github.com/tencent/codeanalysis/tree/main/server/projects/login/"
    click MainSvc "https://github.com/tencent/codeanalysis/tree/main/server/projects/main/"
    click AnalysisSvc "https://github.com/tencent/codeanalysis/tree/main/server/projects/analysis/"
    click FileSvc "https://github.com/tencent/codeanalysis/tree/main/server/projects/file/"
    click SCMProxy "https://github.com/tencent/codeanalysis/tree/main/server/projects/scmproxy/"

    %% Data Tier
    subgraph "Data Tier"
        DB["MySQL/PostgreSQL"]:::storage
        ObjectStore["MinIO / S3"]:::storage
        MessageBroker["RabbitMQ / Redis"]:::queue
    end

    %% External Systems
    Git["Git/GitHub/GitLab"]:::external
    CICD["CI Servers"]:::external

    %% Connections - HTTP
    Browser -->|HTTP| APIGateway
    CLI -->|REST API| APIGateway
    Jenkins -->|REST API| APIGateway
    IDE -->|REST API| APIGateway

    LoginUI -->|REST API| APIGateway
    Framework -->|REST API| APIGateway
    Layout -->|REST API| APIGateway
    Manage -->|REST API| APIGateway
    AnalysisUI -->|REST API| APIGateway
    Shared -->|REST API| APIGateway

    APIGateway -->|HTTP| LoginSvc
    APIGateway -->|HTTP| MainSvc
    APIGateway -->|HTTP| AnalysisSvc
    APIGateway -->|HTTP| FileSvc
    APIGateway -->|HTTP| SCMProxy

    %% Async task processing
    MainSvc -.->|AMQP/Redis enqueue| CeleryBroker
    AnalysisSvc -.->|AMQP/Redis enqueue| CeleryBroker
    CeleryBroker -->|AMQP/Redis| CeleryWorkers
    CeleryWorkers -->|SQL| DB
    CeleryWorkers -->|Object storage| ObjectStore

    %% Service to storage
    MainSvc -->|SQL| DB
    FileSvc -->|Object storage| ObjectStore
    SCMProxy -->|HTTP| Git

    %% CI Servers integration
    CICD -->|Webhooks/REST| APIGateway

    %% Class Definitions
    classDef frontend fill:#D0E8FF,stroke:#02457A,color:#02457A;
    classDef service fill:#E0F2E9,stroke:#116A37,color:#116A37;
    classDef queue fill:#FFEFD5,stroke:#E69500,color:#E69500,stroke-dasharray: 5 5;
    classDef worker fill:#FFF4E5,stroke:#E37B00,color:#E37B00;
    classDef storage fill:#F0F0F0,stroke:#888888,color:#444444,stroke-dasharray: 2 2;
    classDef external fill:#F5F5F5,stroke:#666666,color:#333333;
```
