# sleep1223/fast-soy-admin architecture

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

- Interactive diagram: https://gitdiagram.com/sleep1223/fast-soy-admin
- Repository: https://github.com/sleep1223/fast-soy-admin

## Overview

##### Project Type and Purpose
- That this is a full-stack, modern admin panel solution.
- The backend uses FastAPI, Pydantic, Tortoise ORM, and includes API endpoints (organized under app/api), controllers, core utilities (middlewares, dependencies, exception handling), logging, and database models.
- The frontend is built with Vue3, Vite, TypeScript, and leverages Pinia, UnoCSS along with custom packages (like axios, hooks, materials, etc.). The monorepo is managed by pnpm.
- The project also supports Docker deployment, showing production readiness and containerized architecture.

##### Analyzing the File Structure to Identify the Main Components
a. Backend Components (located in the “app” folder):
- API Layer: “app/api/v1” further splits into modules like “auth”, “route”, and “system_manage” (with functionalities such as logs, menus, roles, and users). Include “app/api/v1/utils.py” for utility endpoints.
- Controllers: Located in “app/controllers”, handling business logic across API endpoints (files like api.py, log.py, menu.py, role.py, user.py).
- Core and Middleware: “app/core” holds essential modules for background tasks, CRUD operations, dependency injection, error handling, app initialization, and middleware.
- Models and Schemas: “app/models/system” and “app/schemas” represent the domain models and data validation schemas respectively.
- Logging and Utilities: “app/log” for logging functionality and “app/utils” for security and other helper tools.
- Configuration & Settings: “app/settings” contains configuration settings used at runtime.

b. Frontend Components (located in the “web” folder):
- Main Application: Entry point (web/src/main.ts) and the primary Vue application (App.vue).
- Layouts and Views: Organized under “web/src/layouts” and “web/src/views”, covering multiple pages (home, login, error pages, management pages, plugin pages, etc.) as well as reusable layout components.
- Components & Modules: “web/src/components” holds both common and custom components.
- Routing and Plugins: A complete routing setup (web/src/router) is provided along with various plugins (web/src/plugins) to enhance functionality.
- Packages: The “web/packages” folder indicates a monorepo structure that includes auxiliary libraries (alova, axios, hooks, materials, etc.) which further illustrate the modularity of the frontend.
- Assets, styles, internationalization (locales), and utilities are clearly defined to support a robust client-side architecture.

c. Deployment and Configuration
- Docker and Compose files (.dockerignore, docker-compose.yml) show the containerized deployment nature.
- Build configurations and environment files (e.g., .env, deploy/web.conf, pnpm workspace files) highlight both development and production settings.

##### Architectural Patterns and Design Principles
- The backend exhibits a separation of concerns using an MVC-like pattern:
- Controllers and API endpoints handle HTTP requests.
- Models and Schemas manage data validation and data mapping.
- Middlewares and core modules handle cross-cutting concerns such as error handling and dependency injection.
- The frontend follows a component-based design pattern through Vue3 with clearly defined layouts, routing, and state management (Pinia).
- Monorepo approach (via pnpm workspace) that supports multiple packages and ensures modularity.

##### Additional Detail
- Use annotations or side-notes to indicate important technologies such as FastAPI, Vue3, Tortoise ORM, Pinia, and UnoCSS.
- Monorepo management via pnpm and note the build/deployment scripts that facilitate Docker deployments.
- Optionally, if useful, include external services mentioned in the README (like Apifox for documentation) to provide fuller context.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Backend Subgraph
    subgraph "Backend (FastAPI)"
        API["API Layer"]:::backend
        Controllers["Controllers"]:::backend
        Core["Core Services & Middlewares"]:::backend
        Models["Database Models"]:::backend
        Schemas["Schemas"]:::backend
        Logging["Logging"]:::backend
        Utils["Utilities"]:::backend
        Config["Configuration & Settings"]:::backend
    end

    %% Database Node
    Database[(Database)]:::database

    %% Frontend Subgraph
    subgraph "Frontend (Vue3/Vite)"
        FE_Main["Main Application"]:::frontend
        FE_Layouts["Layouts & Views"]:::frontend
        FE_Components["Components"]:::frontend
        FE_Routing["Routing & Plugins"]:::frontend
        FE_Packages["Packages/Modules"]:::frontend
    end

    %% Docker / Deployment Node
    Docker["Docker Compose/Deployment"]:::docker

    %% Backend Relationships
    API -->|"calls"| Controllers
    Controllers -->|"utilizes"| Core
    Core -->|"processes"| Models
    Core -->|"validates"| Schemas
    Models -->|"CRUD"| Database
    Schemas -->|"maps"| Database
    Core -->|"logs"| Logging
    Core -->|"uses"| Utils
    Config -->|"configures"| API
    Config -->|"configures"| Core

    %% Frontend Relationships
    FE_Main -->|"renders"| FE_Layouts
    FE_Main -->|"initiates"| FE_Routing
    FE_Main -->|"displays"| FE_Components
    FE_Routing -->|"integrates"| FE_Packages
    FE_Layouts -->|"composes"| FE_Components

    %% Integration between Frontend and Backend
    FE_Main ---|"HTTP calls"| API

    %% Deployment Relationships
    Docker ---|"deploys"| API
    Docker ---|"deploys"| FE_Main

    %% Click Events for Backend Components
    click API "https://github.com/sleep1223/fast-soy-admin/tree/dev/app/api/v1"
    click Controllers "https://github.com/sleep1223/fast-soy-admin/tree/dev/app/controllers"
    click Core "https://github.com/sleep1223/fast-soy-admin/tree/dev/app/core"
    click Models "https://github.com/sleep1223/fast-soy-admin/tree/dev/app/models/system"
    click Schemas "https://github.com/sleep1223/fast-soy-admin/tree/dev/app/schemas"
    click Logging "https://github.com/sleep1223/fast-soy-admin/tree/dev/app/log"
    click Utils "https://github.com/sleep1223/fast-soy-admin/tree/dev/app/utils"
    click Config "https://github.com/sleep1223/fast-soy-admin/tree/dev/app/settings"

    %% Click Events for Frontend Components
    click FE_Main "https://github.com/sleep1223/fast-soy-admin/tree/dev/web/src"
    click FE_Layouts "https://github.com/sleep1223/fast-soy-admin/tree/dev/web/src/layouts"
    click FE_Components "https://github.com/sleep1223/fast-soy-admin/tree/dev/web/src/components"
    click FE_Routing "https://github.com/sleep1223/fast-soy-admin/tree/dev/web/src/router"
    click FE_Packages "https://github.com/sleep1223/fast-soy-admin/tree/dev/web/packages"

    %% Click Event for Docker/Deployment
    click Docker "https://github.com/sleep1223/fast-soy-admin/blob/dev/docker-compose.yml"

    %% Styles
    classDef backend fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef frontend fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef database fill:#F9E79F,stroke:#B7950B,stroke-width:2px,stroke-dasharray: 5 5;
    classDef docker fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
```
