# mizhexiaoxiao/vue-fastapi-admin architecture

> Architecture diagram of the GitHub repository mizhexiaoxiao/vue-fastapi-admin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mizhexiaoxiao/vue-fastapi-admin
- Repository: https://github.com/mizhexiaoxiao/vue-fastapi-admin

## Overview

1. This repository is a split front-end/back-end admin platform. The backend is a FastAPI service under `app/`, and the frontend is a separate Vue 3 + Vite application under `web/`. The codebase is organized around an RBAC-driven system admin domain rather than a general-purpose web app.

2. The backend entry point is `run.py`, with application setup concentrated in `app/core/init_app.py`. Request handling is versioned under `app/api/v1`, so the public API boundary is explicitly `/api/v1/...`. Core middleware, dependency injection, and exception handling live in `app/core`, shaping the global request lifecycle before control reaches business logic.

3. The backend follows a layered flow: API routers in `app/api/v1/*` call controllers in `app/controllers/*`, which then use shared CRUD helpers in `app/core/crud.py`, data models in `app/models/*`, and Pydantic schemas in `app/schemas/*`. This keeps transport, business rules, and persistence concerns separated.

4. The main backend domains are administrative and permission-centric: users, roles, menus, departments, API permissions, and audit logs. The presence of `app/api/v1/apis`, `users`, `roles`, `menus`, `depts`, `auditlog`, plus matching controllers and schemas, indicates the system manages both page/menu access and fine-grained interface access.

5. Authentication is JWT-based. `app/utils/jwt_utils.py` and `app/utils/password.py` handle token creation/verification and password processing, while `app/core/dependency.py` likely wires authenticated/current-user context into protected endpoints. This is the security boundary that gates both data access and permission checks.

6. Operational concerns are first-class on the backend: `app/log/log.py` provides logging, `app/core/exceptions.py` centralizes error handling, `app/core/ctx.py` suggests request-scoped context propagation, and `app/core/bgtask.py` covers asynchronous background work. These pieces sit horizontally across all domains rather than belonging to one feature.

7. The frontend is a single-page admin console built with Vue 3, Naive UI, Pinia, and Vite. Its shell is defined in `web/src/layout`, with reusable header/sidebar/tabs components and page containers, while feature pages live in `web/src/views` for login, workbench, profile, and system management screens.

8. Frontend routing is not static. `web/src/router/guard/*` plus the permission store in `web/src/store/modules/permission` indicate the app builds or filters routes based on the authenticated user’s roles/menus. This matches the backend RBAC model and is the key data flow that turns permissions into visible navigation and accessible pages.

9. State and identity are managed on the client through Pinia modules for app state, user state, tags, and permissions, with token persistence in `web/src/utils/auth` and browser storage helpers in `web/src/utils/storage`. Route guards enforce login, page loading state, title updates, and access control before a view renders.

10. Feature pages are built on a shared admin UI toolkit: generic CRUD table/modal components, query bars, icon pickers, and common page wrappers under `web/src/components`. These abstractions let system pages for users, roles, menus, departments, APIs, and audit logs follow the same interaction pattern and keep the UI consistent.

11. The frontend talks to the backend through a centralized HTTP layer in `web/src/utils/http`, with API modules under `web/src/api`. That separation means views depend on stable client wrappers rather than calling the backend directly, making auth headers, error handling, and response interception uniform across the app.

12. Deployment is container-aware. The repo includes a `Dockerfile`, `deploy/entrypoint.sh`, and `deploy/web.conf`, suggesting production packaging with an HTTP server/reverse proxy in front of the built frontend and API service. Local development remains split: `python run.py` for the backend and `pnpm dev` for the frontend.

Main entry points: [`app/controllers`](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/controllers) (Controllers), [`web/src/main.js`](https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/web/src/main.js) (main.js), [`app/core/init_app.py`](https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/app/core/init_app.py) (App init), [`app/core`](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/core) (Core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_run(("run.py<br/>entrypoint<br/>[run.py]"))
  node_init_app["App init<br/>bootstrap<br/>[init_app.py]"]
  node_core["Core<br/>cross-cutting"]
  node_api_v1["API v1<br/>http routes"]
  node_controllers["Controllers<br/>service layer"]
  node_crud["CRUD<br/>data access<br/>[crud.py]"]
  node_models["Models"]
  node_schemas["Schemas<br/>pydantic"]
  node_auth_utils["Auth utils<br/>security"]
  node_domains["Admin domains<br/>rbac features"]
  node_log["Logging<br/>observability<br/>[log.py]"]
end

subgraph group_frontend["Frontend"]
  node_web_main(("main.js<br/>entrypoint<br/>[main.js]"))
  node_layout["Layout shell<br/>ui shell"]
  node_router["Router<br/>navigation"]
  node_stores["Pinia stores<br/>state"]
  node_perm_flow["Permission flow<br/>rbac routing"]
  node_http["HTTP client<br/>api client"]
  node_api_modules["API modules<br/>endpoint wrappers"]
  node_views["Views<br/>pages"]
  node_components["UI kit<br/>shared components"]
end

subgraph group_ops["Deployment"]
  node_deploy["Deploy files<br/>packaging"]
  node_dockerfile["Dockerfile<br/>container build"]
end

node_run -->|"starts"| node_init_app
node_init_app -->|"wires"| node_core
node_init_app -->|"mounts"| node_api_v1
node_api_v1 -->|"calls"| node_controllers
node_controllers -->|"uses"| node_crud
node_controllers -->|"reads/writes"| node_models
node_controllers -->|"validates"| node_schemas
node_controllers -->|"secures"| node_auth_utils
node_domains -->|"implemented by"| node_controllers
node_core -->|"logs"| node_log
node_core -->|"auth context"| node_auth_utils
node_web_main -->|"renders"| node_layout
node_web_main -->|"registers"| node_router
node_web_main -->|"initializes"| node_stores
node_router -->|"guards"| node_perm_flow
node_perm_flow -->|"uses"| node_stores
node_stores -->|"uses"| node_http
node_api_modules -->|"wraps"| node_http
node_views -->|"calls"| node_api_modules
node_views -->|"composes"| node_components
node_layout -->|"hosts"| node_views
node_deploy -->|"packages"| node_dockerfile
node_deploy -->|"serves"| node_run

click node_run "https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/run.py"
click node_init_app "https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/app/core/init_app.py"
click node_core "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/core"
click node_api_v1 "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/api/v1"
click node_controllers "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/controllers"
click node_crud "https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/app/core/crud.py"
click node_models "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/models"
click node_schemas "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/schemas"
click node_auth_utils "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/utils"
click node_domains "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/api/v1/users"
click node_log "https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/app/log/log.py"
click node_web_main "https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/web/src/main.js"
click node_layout "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/layout"
click node_router "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/router"
click node_stores "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/store/modules"
click node_perm_flow "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/store/modules/permission"
click node_http "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/utils/http"
click node_api_modules "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/api"
click node_views "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/views"
click node_components "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/components"
click node_deploy "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/deploy"
click node_dockerfile "https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/Dockerfile"

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_run,node_init_app,node_core,node_api_v1,node_controllers,node_crud,node_models,node_schemas,node_auth_utils,node_domains,node_log toneBlue
class node_web_main,node_layout,node_router,node_stores,node_perm_flow,node_http,node_api_modules,node_views,node_components toneAmber
class node_deploy,node_dockerfile toneMint
```

## Components

### Backend

FastAPI service and RBAC domain logic

- [run.py](https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/run.py): entrypoint · Backend process entry · `run.py`
- [App init](https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/app/core/init_app.py): bootstrap · Builds the FastAPI application and wires core setup · `app/core/init_app.py`
- [Core](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/core): cross-cutting · Middleware, dependencies, context, exceptions, background tasks · `app/core`
- [API v1](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/api/v1): http routes · Versioned public API boundary · `app/api/v1`
- [Controllers](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/controllers): service layer · Domain orchestration between routes and data access · `app/controllers`
- [CRUD](https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/app/core/crud.py): data access · Shared persistence helpers · `app/core/crud.py`
- [Models](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/models): orm models · Database entities and enums · `app/models`
- [Schemas](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/schemas): pydantic · Request and response contracts · `app/schemas`
- [Auth utils](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/utils): security · JWT and password helpers · `app/utils`
- [Admin domains](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/app/api/v1/users): rbac features · Users, roles, menus, departments, APIs, and audit logs · `app/api/v1/users`
- [Logging](https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/app/log/log.py): observability · Application logging setup · `app/log/log.py`

### Frontend

Vue 3 admin console and client state

- [main.js](https://github.com/mizhexiaoxiao/vue-fastapi-admin/blob/main/web/src/main.js): entrypoint · Frontend bootstrap · `web/src/main.js`
- [Layout shell](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/layout): ui shell · Header, sidebar, tags, and app container · `web/src/layout`
- [Router](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/router): navigation · Route definitions and guards · `web/src/router`
- [Pinia stores](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/store/modules): state · App, user, tags, and permission state · `web/src/store/modules`
- [Permission flow](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/store/modules/permission): rbac routing · Builds visible routes from user roles and menus · `web/src/store/modules/permission`
- [HTTP client](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/utils/http): api client · Centralized request layer and interceptors · `web/src/utils/http`
- [API modules](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/api): endpoint wrappers · Feature-specific backend client modules · `web/src/api`
- [Views](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/views): pages · Login, workbench, profile, and system management pages · `web/src/views`
- [UI kit](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/web/src/components): shared components · CRUD tables, modals, query bars, icons, and page wrappers · `web/src/components`

### Deployment

Container and reverse-proxy packaging

- [Deploy files](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/deploy): packaging · Entrypoint and reverse-proxy configuration · `deploy`
- [Dockerfile](https://github.com/mizhexiaoxiao/vue-fastapi-admin/tree/main/Dockerfile): container build · Container image definition · `Dockerfile`

## Connections

- run.py → App init: starts · Entry point creates the application
- App init → Core: wires · Registers middleware, dependencies, and error handling
- App init → API v1: mounts · Attaches versioned routes
- API v1 → Controllers: calls · Routers delegate to domain controllers
- Controllers → CRUD: uses · Controllers share persistence helpers
- Controllers → Models: reads/writes · Business logic works with ORM entities
- Controllers → Schemas: validates · Input and output data shaped by schemas
- Controllers → Auth utils: secures · Authentication and password handling support protected actions
- Admin domains → Controllers: implemented by · Domain routes map to controller modules
- Core → Logging: logs · Cross-cutting logging support
- Core → Auth utils: auth context · Dependencies expose current-user and token context
- main.js → Layout shell: renders · App bootstraps the shell
- main.js → Router: registers · Router is installed at startup
- main.js → Pinia stores: initializes · Pinia state is created on launch
- Router → Permission flow: guards · Route access is filtered by permissions
- Permission flow → Pinia stores: uses · Permission store drives navigation state
- Pinia stores → HTTP client: uses · Client state relies on backend requests
- API modules → HTTP client: wraps · API modules share the HTTP layer
- Views → API modules: calls · Pages use stable client wrappers
- Views → UI kit: composes · Pages are built from reusable admin UI
- Layout shell → Views: hosts · Shell contains routed pages
- Deploy files → Dockerfile: packages · Deployment artifacts support container builds
- Deploy files → run.py: serves · Entrypoint launches backend in production
