# ymfe/yapi architecture

> Architecture diagram of the GitHub repository ymfe/yapi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ymfe/yapi
- Repository: https://github.com/ymfe/yapi

## Overview

YApi is a collaborative API-management platform: users sign in, organize groups and projects, define and maintain interface documentation, then test interfaces or serve mocks. The server exposes API routes and plugin capabilities, while MongoDB is the documented deployment datastore. Additional branches cover data import/export, Swagger synchronization, wiki documentation, and usage statistics. The excerpts establish application startup, route registration, and several plugin-controller responsibilities; many core controller and client implementations were not sampled, so unverified connections are omitted or marked dashed.

Main entry points: [`client/Application.js`](https://github.com/ymfe/yapi/blob/master/client/Application.js) (Client application), [`server/router.js`](https://github.com/ymfe/yapi/blob/master/server/router.js) (API router), [`server/app.js`](https://github.com/ymfe/yapi/blob/master/server/app.js) (Koa application), [`client/containers/Project/Interface`](https://github.com/ymfe/yapi/tree/master/client/containers/Project/Interface) (Interface editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_webapp["Client application<br/>[Application.js]"]
  node_home["Home and projects<br/>[Home.js]"]
  node_projectui["Project workspace"]
  node_groupui["Group management"]
  node_interfaceui["Interface editor"]
  node_runui["Interface testing<br/>[Run.js]"]
end

subgraph group_core["API platform"]
  node_backend["Koa application<br/>[app.js]"]
  node_router["API router<br/>[router.js]"]
  node_userapi["User API<br/>[user.js]"]
  node_projectapi["Project API<br/>[project.js]"]
  node_interfaceapi["Interface API<br/>[interface.js]"]
  node_collectionapi["Test collections<br/>[interfaceCol.js]"]
  node_mockserver["Mock server<br/>[mockServer.js]"]
  node_markdown["Markdown rendering<br/>[markdown.js]"]
end

subgraph group_plugins["Product extensions"]
  node_advancedmock["Mock expectations<br/>[controller.js]"]
  node_import["API import"]
  node_export["API export<br/>[controller.js]"]
  node_swaggerexport["OpenAPI export<br/>[controller.js]"]
  node_sync["Swagger auto-sync<br/>[syncController.js]"]
  node_wiki["Project wiki<br/>[controller.js]"]
  node_statistics["Usage statistics<br/>[controller.js]"]
end

subgraph group_data["Persistence"]
  node_mongodb[("MongoDB")]
end

node_user(("Platform user"))

node_user -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_home
node_webapp -->|"routes to"| node_groupui
node_webapp -->|"routes to"| node_projectui
node_home -.->|"opens"| node_projectui
node_projectui -.->|"manages"| node_interfaceui
node_interfaceui -.->|"runs"| node_runui
node_webapp -.->|"requests"| node_backend
node_backend -->|"mounts"| node_router
node_router -->|"dispatches"| node_userapi
node_router -->|"dispatches"| node_projectapi
node_router -->|"dispatches"| node_interfaceapi
node_router -->|"dispatches"| node_collectionapi
node_backend -->|"installs"| node_mockserver
node_interfaceui -.->|"imports formats"| node_import
node_user -.->|"configures expectations"| node_advancedmock
node_user -.->|"exports documentation"| node_export
node_user -.->|"exports OpenAPI"| node_swaggerexport
node_user -.->|"configures sync"| node_sync
node_user -.->|"edits wiki"| node_wiki
node_user -.->|"views statistics"| node_statistics
node_export -->|"renders markdown"| node_markdown
node_backend -.->|"connects to"| node_mongodb

click node_webapp "https://github.com/ymfe/yapi/blob/master/client/Application.js"
click node_home "https://github.com/ymfe/yapi/blob/master/client/containers/Home/Home.js"
click node_projectui "https://github.com/ymfe/yapi/tree/master/client/containers/Project"
click node_groupui "https://github.com/ymfe/yapi/tree/master/client/containers/Group"
click node_interfaceui "https://github.com/ymfe/yapi/tree/master/client/containers/Project/Interface"
click node_runui "https://github.com/ymfe/yapi/blob/master/client/containers/Project/Interface/InterfaceList/Run/Run.js"
click node_backend "https://github.com/ymfe/yapi/blob/master/server/app.js"
click node_router "https://github.com/ymfe/yapi/blob/master/server/router.js"
click node_userapi "https://github.com/ymfe/yapi/blob/master/server/controllers/user.js"
click node_projectapi "https://github.com/ymfe/yapi/blob/master/server/controllers/project.js"
click node_interfaceapi "https://github.com/ymfe/yapi/blob/master/server/controllers/interface.js"
click node_collectionapi "https://github.com/ymfe/yapi/blob/master/server/controllers/interfaceCol.js"
click node_mockserver "https://github.com/ymfe/yapi/blob/master/server/middleware/mockServer.js"
click node_advancedmock "https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-advanced-mock/controller.js"
click node_import "https://github.com/ymfe/yapi/tree/master/exts/yapi-plugin-import-swagger"
click node_export "https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-export-data/controller.js"
click node_swaggerexport "https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-export-swagger2-data/controller.js"
click node_sync "https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-swagger-auto-sync/controller/syncController.js"
click node_wiki "https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-wiki/controller.js"
click node_statistics "https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-statistics/controller.js"
click node_markdown "https://github.com/ymfe/yapi/blob/master/common/markdown.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_home,node_projectui,node_groupui,node_interfaceui,node_runui,node_user toneBlue
class node_backend,node_router,node_userapi,node_projectapi,node_interfaceapi,node_collectionapi,node_mockserver,node_markdown toneAmber
class node_advancedmock,node_import,node_export,node_swaggerexport,node_sync,node_wiki,node_statistics toneMint
class node_mongodb toneRose
```

## Components

### Web application

- [Client application](https://github.com/ymfe/yapi/blob/master/client/Application.js): `client/Application.js`
- [Home and projects](https://github.com/ymfe/yapi/blob/master/client/containers/Home/Home.js): `client/containers/Home/Home.js`
- [Project workspace](https://github.com/ymfe/yapi/tree/master/client/containers/Project): `client/containers/Project`
- [Group management](https://github.com/ymfe/yapi/tree/master/client/containers/Group): `client/containers/Group`
- [Interface editor](https://github.com/ymfe/yapi/tree/master/client/containers/Project/Interface): `client/containers/Project/Interface`
- [Interface testing](https://github.com/ymfe/yapi/blob/master/client/containers/Project/Interface/InterfaceList/Run/Run.js): `client/containers/Project/Interface/InterfaceList/Run/Run.js`

### API platform

- [Koa application](https://github.com/ymfe/yapi/blob/master/server/app.js): `server/app.js`
- [API router](https://github.com/ymfe/yapi/blob/master/server/router.js): `server/router.js`
- [User API](https://github.com/ymfe/yapi/blob/master/server/controllers/user.js): `server/controllers/user.js`
- [Project API](https://github.com/ymfe/yapi/blob/master/server/controllers/project.js): `server/controllers/project.js`
- [Interface API](https://github.com/ymfe/yapi/blob/master/server/controllers/interface.js): `server/controllers/interface.js`
- [Test collections](https://github.com/ymfe/yapi/blob/master/server/controllers/interfaceCol.js): `server/controllers/interfaceCol.js`
- [Mock server](https://github.com/ymfe/yapi/blob/master/server/middleware/mockServer.js): `server/middleware/mockServer.js`
- [Markdown rendering](https://github.com/ymfe/yapi/blob/master/common/markdown.js): `common/markdown.js`

### Product extensions

- [Mock expectations](https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-advanced-mock/controller.js): `exts/yapi-plugin-advanced-mock/controller.js`
- [API import](https://github.com/ymfe/yapi/tree/master/exts/yapi-plugin-import-swagger): `exts/yapi-plugin-import-swagger`
- [API export](https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-export-data/controller.js): `exts/yapi-plugin-export-data/controller.js`
- [OpenAPI export](https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-export-swagger2-data/controller.js): `exts/yapi-plugin-export-swagger2-data/controller.js`
- [Swagger auto-sync](https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-swagger-auto-sync/controller/syncController.js): `exts/yapi-plugin-swagger-auto-sync/controller/syncController.js`
- [Project wiki](https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-wiki/controller.js): `exts/yapi-plugin-wiki/controller.js`
- [Usage statistics](https://github.com/ymfe/yapi/blob/master/exts/yapi-plugin-statistics/controller.js): `exts/yapi-plugin-statistics/controller.js`

### Persistence

- **MongoDB**

### Other components

- **Platform user**

## Connections

- Platform user → Client application: uses (evidence: `README.md`)
- Client application → Home and projects: routes to (evidence: `client/Application.js`)
- Client application → Group management: routes to (evidence: `client/Application.js`)
- Client application → Project workspace: routes to (evidence: `client/Application.js`)
- Home and projects → Project workspace: opens
- Project workspace → Interface editor: manages
- Interface editor → Interface testing: runs
- Client application → Koa application: requests
- Koa application → API router: mounts (evidence: `server/app.js`)
- API router → User API: dispatches (evidence: `server/router.js`)
- API router → Project API: dispatches (evidence: `server/router.js`)
- API router → Interface API: dispatches (evidence: `server/router.js`)
- API router → Test collections: dispatches (evidence: `server/router.js`)
- Koa application → Mock server: installs (evidence: `server/app.js`)
- Interface editor → API import: imports formats
- Platform user → Mock expectations: configures expectations
- Platform user → API export: exports documentation
- Platform user → OpenAPI export: exports OpenAPI
- Platform user → Swagger auto-sync: configures sync
- Platform user → Project wiki: edits wiki
- Platform user → Usage statistics: views statistics
- API export → Markdown rendering: renders markdown (evidence: `exts/yapi-plugin-export-data/controller.js`)
- Koa application → MongoDB: connects to
