# usdt **Repository Path**: konghai-studio/usdt ## Basic Information - **Project Name**: usdt - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-05-23 - **Last Updated**: 2025-04-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Full Stack FastAPI Template 全栈 FastAPI 模板 Test Coverage 测试 覆盖率 ## Technology Stack and Features ## 技术栈和功能 - ⚡ [**FastAPI**](https://fastapi.tiangolo.com) for the Python backend API. - 🧰 [SQLModel](https://sqlmodel.tiangolo.com) for the Python SQL database interactions (ORM). - 🔍 [Pydantic](https://docs.pydantic.dev), used by FastAPI, for the data validation and settings management. - 💾 [PostgreSQL](https://www.postgresql.org) as the SQL database. - 🚀 [React](https://react.dev) for the frontend. - 💃 Using TypeScript, hooks, Vite, and other parts of a modern frontend stack. - 🎨 [Chakra UI](https://chakra-ui.com) for the frontend components. - 🤖 An automatically generated frontend client. - 🦇 Dark mode support. - 🐋 [Docker Compose](https://www.docker.com) for development and production. - 🔒 Secure password hashing by default. - 🔑 JWT (JSON Web Token) authentication. - 📫 Email based password recovery. - ✅ Tests with [Pytest](https://pytest.org). - 📞 [Traefik](https://traefik.io) as a reverse proxy / load balancer. - 🚢 Deployment instructions using Docker Compose, including how to set up a frontend Traefik proxy to handle automatic HTTPS certificates. - 🏭 CI (continuous integration) and CD (continuous deployment) based on GitHub Actions. - ⚡ [**FastAPI**](https://fastapi.tiangolo.com) 用于 Python 后端 API。 - 🧰 [SQLModel](https://sqlmodel.tiangolo.com) 用于 Python SQL 数据库交互(ORM)。 - 🔍 [Pydantic](https://docs.pydantic.dev),由 FastAPI 使用,用于数据验证和设置管理。 - 💾 [PostgreSQL](https://www.postgresql.org) 作为 SQL 数据库。 - 🚀 [React](https://react.dev) 用于前端。 - 💃 使用 TypeScript、hooks、Vite 和其他现代前端技术栈。 - 🎨 [Chakra UI](https://chakra-ui.com) 用于前端组件。 - 🤖 自动生成的前端客户端。 - 🦇 支持暗模式。 - 🐋 [Docker Compose](https://www.docker.com) 用于开发和生产。 - 🔒 默认安全的密码哈希。 - 🔑 JWT(JSON Web Token)认证。 - 📫 基于电子邮件的密码恢复。 - ✅ 使用 [Pytest](https://pytest.org) 进行测试。 - 📞 [Traefik](https://traefik.io) 作为反向代理/负载均衡器。 - 🚢 使用 Docker Compose 的部署说明,包括如何设置前端 Traefik 代理以处理自动 HTTPS 证书。 - 🏭 基于 GitHub Actions 的 CI(持续集成)和 CD(持续部署)。 ### Dashboard Login 仪表板登录 [![API docs](img/login.png)](https://github.com/tiangolo/full-stack-fastapi-template) [![API 文档](img/login.png)](https://github.com/tiangolo/full-stack-fastapi-template) ### Dashboard - Admin 仪表板 - 管理员 [![API docs](img/dashboard.png)](https://github.com/tiangolo/full-stack-fastapi-template) [![API 文档](img/dashboard.png)](https://github.com/tiangolo/full-stack-fastapi-template) ### Dashboard - Create User 仪表板 - 创建用户 [![API docs](img/dashboard-create.png)](https://github.com/tiangolo/full-stack-fastapi-template) [![API 文档](img/dashboard-create.png)](https://github.com/tiangolo/full-stack-fastapi-template) ### Dashboard - Items 仪表板 - 项目 [![API docs](img/dashboard-items.png)](https://github.com/tiangolo/full-stack-fastapi-template) [![API 文档](img/dashboard-items.png)](https://github.com/tiangolo/full-stack-fastapi-template) ### Dashboard - User Settings 仪表板 - 用户设置 [![API docs](img/dashboard-user-settings.png)](https://github.com/tiangolo/full-stack-fastapi-template) [![API 文档](img/dashboard-user-settings.png)](https://github.com/tiangolo/full-stack-fastapi-template) ### Dashboard - Dark Mode ### 仪表板 - 暗模式 [![API docs](img/dashboard-dark.png)](https://github.com/tiangolo/full-stack-fastapi-template) [![API 文档](img/dashboard-dark.png)](https://github.com/tiangolo/full-stack-fastapi-template) ### Interactive API Documentation ### 互动式 API 文档 [![API docs](img/docs.png)](https://github.com/tiangolo/full-stack-fastapi-template) [![API 文档](img/docs.png)](https://github.com/tiangolo/full-stack-fastapi-template) ## How To Use It ## 如何使用 You can **just fork or clone** this repository and use it as is. 你可以**直接分叉或克隆**这个仓库并按原样使用。 ✨ It just works. ✨ ✨ 它就是有效。✨ ### How to Use a Private Repository ### 如何使用私人仓库 If you want to have a private repository, GitHub won't allow you to simply fork it as it doesn't allow changing the visibility of forks. 如果你想要一个私人仓库,GitHub 不允许你简单地分叉它,因为它不允许更改分叉的可见性。 But you can do the following: 但你可以做以下事情: - Create a new GitHub repo, for example `my-full-stack`. - Clone this repository manually, set the name with the name of the project you want to use, for example `my-full-stack`: - 创建一个新的 GitHub 仓库,例如 `my-full-stack`。 - 手动克隆此仓库,并将名称设置为您想使用的项目名称,例如 `my-full-stack`: ```bash git clone git@github.com:tiangolo/full-stack-fastapi-template.git my-full-stack ``` - Enter into the new directory: - 进入新目录: ```bash cd my-full-stack ``` - Set the new origin to your new repository, copy it from the GitHub interface, for example: - 将新的源设置为您的新存储库,从 GitHub 界面复制它,例如: ```bash git remote set-url origin git@github.com:octocat/my-full-stack.git ``` - Add this repo as another "remote" to allow you to get updates later: - 将此仓库添加为另一个“远程”以便以后获取更新: ```bash git remote add upstream git@github.com:tiangolo/full-stack-fastapi-template.git ``` ```bash git remote add upstream git@github.com:tiangolo/full-stack-fastapi-template.git ``` - Push the code to your new repository: - 将代码推送到你的新仓库: ```bash git push -u origin master ``` ### Update From the Original Template ### 从原始模板更新 After cloning the repository, and after doing changes, you might want to get the latest changes from this original template. 在克隆存储库并进行更改后,您可能希望获取此原始模板的最新更改。 - Make sure you added the original repository as a remote, you can check it with: 确保您已将原始仓库添加为远程仓库,您可以通过以下方式检查: ```bash git remote -v ```bash git remote -v ``` origin git@github.com:octocat/my-full-stack.git (fetch) origin git@github.com:octocat/my-full-stack.git (push) upstream git@github.com:tiangolo/full-stack-fastapi-template.git (fetch) upstream git@github.com:tiangolo/full-stack-fastapi-template.git (push) ``` - Pull the latest changes without merging: - 拉取最新更改而不合并: ```bash git pull --no-commit upstream master ``` This will download the latest changes from this template without committing them, that way you can check everything is right before committing. 这将下载此模板的最新更改而不提交它们,这样你可以在提交之前检查一切是否正确。 - If there are conflicts, solve them in your editor. - 如果有冲突,请在编辑器中解决。 - Once you are done, commit the changes: 完成后,提交更改: ```bash git merge --continue ``` ### Configure 配置 You can then update configs in the `.env` files to customize your configurations. 然后,您可以更新 `.env` 文件中的配置以自定义您的配置。 Before deploying it, make sure you change at least the values for: 在部署之前,请确保至少更改以下值: - `SECRET_KEY` - `FIRST_SUPERUSER_PASSWORD` - `POSTGRES_PASSWORD` You can (and should) pass these as environment variables from secrets. 您可以(并且应该)将这些作为环境变量从机密中传递。 Read the [deployment.md](./deployment.md) docs for more details. 阅读[deployment.md](./deployment.md)文档以获取更多详细信息。 ### Generate Secret Keys 生成密钥 Some environment variables in the `.env` file have a default value of `changethis`. `.env` 文件中的一些环境变量默认值为 `changethis`。 You have to change them with a secret key, to generate secret keys you can run the following command: 你必须用一个密钥来更换它们,要生成密钥,你可以运行以下命令: ```bash python -c "import secrets; print(secrets.token_urlsafe(32))" ``` Copy the content and use that as password / secret key. And run that again to generate another secure key. 复制内容并将其用作密码/密钥。然后再次运行以生成另一个安全密钥。 ## How To Use It - Alternative With Copier ## 如何使用 - 复印机替代方案 This repository also supports generating a new project using [Copier](https://copier.readthedocs.io). 此存储库还支持使用[Copier](https://copier.readthedocs.io)生成新项目。 It will copy all the files, ask you configuration questions, and update the `.env` files with your answers. 它将复制所有文件,询问你配置问题,并根据你的回答更新 `.env` 文件。 ### Install Copier ### 安装复印机 You can install Copier with: 您可以通过以下方式安装 Copier: ```bash pip install copier ``` Or better, if you have [`pipx`](https://pipx.pypa.io/), you can run it with: 或者更好的是,如果你有[`pipx`](https://pipx.pypa.io/),你可以运行: ```bash pipx install copier ``` **Note**: If you have `pipx`, installing copier is optional, you could run it directly. **注意**:如果你有 `pipx`,安装 copier 是可选的,你可以直接运行它。 ### Generate a Project With Copier ### 使用 Copier 生成项目 Decide a name for your new project's directory, you will use it below. For example, `my-awesome-project`. 为你的新项目目录决定一个名称,你将在下面使用它。例如,`my-awesome-project`。 Go to the directory that will be the parent of your project, and run the command with your project's name: 转到将成为您的项目父目录的目录,并使用您的项目名称运行命令: ```bash copier copy https://github.com/tiangolo/full-stack-fastapi-template my-awesome-project --trust ``` ```bash copier copy https://github.com/tiangolo/full-stack-fastapi-template my-awesome-project --trust ``` If you have `pipx` and you didn't install `copier`, you can run it directly: 如果你有 `pipx` 并且没有安装 `copier`,你可以直接运行它: ```bash pipx run copier copy https://github.com/tiangolo/full-stack-fastapi-template my-awesome-project --trust ``` **Note** the `--trust` option is necessary to be able to execute a [post-creation script](https://github.com/tiangolo/full-stack-fastapi-template/blob/master/.copier/update_dotenv.py) that updates your `.env` files. **注意** `--trust` 选项是必要的,以便能够执行一个[创建后脚本](https://github.com/tiangolo/full-stack-fastapi-template/blob/master/.copier/update_dotenv.py),该脚本会更新你的 `.env` 文件。 ### Input Variables ### 输入变量 Copier will ask you for some data, you might want to have at hand before generating the project. 复印机会向您询问一些数据,您可能希望在生成项目之前准备好这些数据。 But don't worry, you can just update any of that in the `.env` files afterwards. 但别担心,之后你可以在 `.env` 文件中更新任何内容。 The input variables, with their default values (some auto generated) are: 输入变量及其默认值(有些是自动生成的)如下: - `project_name`: (default: `"FastAPI Project"`) The name of the project, shown to API users (in .env). - `stack_name`: (default: `"fastapi-project"`) The name of the stack used for Docker Compose labels and project name (no spaces, no periods) (in .env). - `secret_key`: (default: `"changethis"`) The secret key for the project, used for security, stored in .env, you can generate one with the method above. - `first_superuser`: (default: `"admin@example.com"`) The email of the first superuser (in .env). - `first_superuser_password`: (default: `"changethis"`) The password of the first superuser (in .env). - `smtp_host`: (default: "") The SMTP server host to send emails, you can set it later in .env. - `smtp_user`: (default: "") The SMTP server user to send emails, you can set it later in .env. - `smtp_password`: (default: "") The SMTP server password to send emails, you can set it later in .env. - `emails_from_email`: (default: `"info@example.com"`) The email account to send emails from, you can set it later in .env. - `postgres_password`: (default: `"changethis"`) The password for the PostgreSQL database, stored in .env, you can generate one with the method above. - `sentry_dsn`: (default: "") The DSN for Sentry, if you are using it, you can set it later in .env. - `project_name`: (默认: `"FastAPI Project"`) 项目的名称,显示给 API 用户(在 .env 中)。 - `stack_name`: (默认: `"fastapi-project"`) 用于 Docker Compose 标签和项目名称的堆栈名称(无空格,无句点)(在 .env 中)。 - `secret_key`: (默认: `"changethis"`) 项目的密钥,用于安全性,存储在 .env 中,你可以用上述方法生成一个。 - `first_superuser`: (默认: `"admin@example.com"`) 第一个超级用户的电子邮件(在 .env 中)。 - `first_superuser_password`: (默认: `"changethis"`) 第一个超级用户的密码(在 .env 中)。 - `smtp_host`: (默认: "") 发送电子邮件的 SMTP 服务器主机,你可以稍后在 .env 中设置。 - `smtp_user`: (默认: "") 发送电子邮件的 SMTP 服务器用户,你可以稍后在 .env 中设置。 - `smtp_password`: (默认: "") 发送电子邮件的 SMTP 服务器密码,你可以稍后在 .env 中设置。 - `emails_from_email`: (默认: `"info@example.com"`) 发送电子邮件的账户,你可以稍后在 .env 中设置。 - `postgres_password`: (默认: `"changethis"`) PostgreSQL 数据库的密码,存储在 .env 中,你可以用上述方法生成一个。 - `sentry_dsn`:(默认值:"")Sentry 的 DSN,如果你在使用它,可以稍后在 .env 中设置。 ## Backend Development ## 后端开发 Backend docs: [backend/README.md](./backend/README.md). 后端文档:[backend/README.md](./backend/README.md)。 ## Frontend Development ## 前端开发 Frontend docs: [frontend/README.md](./frontend/README.md). 前端文档:[frontend/README.md](./frontend/README.md)。 ## Deployment ## 部署 Deployment docs: [deployment.md](./deployment.md). 部署文档:[deployment.md](./deployment.md)。 ## Development ## 发展 General development docs: [development.md](./development.md). 通用开发文档:[development.md](./development.md)。 This includes using Docker Compose, custom local domains, `.env` configurations, etc. 这包括使用 Docker Compose、自定义本地域名、`.env`配置等。 ## Release Notes ## 发布说明 Check the file [release-notes.md](./release-notes.md). 查看文件[release-notes.md](./release-notes.md)。 ## License ## 许可证 The Full Stack FastAPI Template is licensed under the terms of the MIT license. 全栈 FastAPI 模板根据 MIT 许可证条款授权。