semvec/pypi-packages huggingface dataset:
fastapi-backend-template 0.1.9
快速创建基于FastAPI的后端项目的脚手架工具
License: MIT
Requires Python: >=3.9
Keywords: fastapi, backend, template, scaffold, generator

# FastAPI Backend Template CLI 使用说明

`fastapi-backend` 是一个用于快速创建基于FastAPI的后端项目的命令行工具。

## 使用方法

### 基本用法

最简单的用法是直接运行命令，使用默认配置：

```bash
fastapi-backend my-project
```

这将在当前目录下创建一个名为 `backend` 的新目录。

### 命令行选项

工具支持以下命令行选项：

```
usage: fastapi-backend [-h] [--db-user DB_USER] [--db-password DB_PASSWORD] [--db-name DB_NAME]
                      [--db-host DB_HOST] [--db-port DB_PORT] [--create-venv] [--output-dir OUTPUT_DIR]
                      [project_name]

FastAPI Backend Template 脚手架工具

位置参数:
  project_name          项目名称 (默认: fastapi-backend)

可选参数:
  -h, --help            显示帮助信息并退出
  --db-user DB_USER     数据库用户名 (默认: root)
  --db-password DB_PASSWORD
                        数据库密码 (默认: password)
  --db-name DB_NAME     数据库名称 (默认: 项目名称转换为下划线形式)
  --db-host DB_HOST     数据库主机 (默认: localhost)
  --db-port DB_PORT     数据库端口 (默认: 3306)
  --create-venv         创建虚拟环境并安装依赖
  --output-dir OUTPUT_DIR
                        输出目录 (默认: 当前目录下的backend)
```

### 示例

1. 创建自定义数据库配置的项目：

```bash
fastapi-backend my-project --db-user myuser --db-password mypass --db-name custom_db
```

2. 指定输出目录：

```bash
fastapi-backend my-project --output-dir /path/to/projects
```

3. 创建虚拟环境：

```bash
fastapi-backend my-project --create-venv
```

## 工具功能

脚手架工具执行以下操作：

1. 复制模板文件到新的backend目录
2. 更新项目名称和相关配置
3. 创建包含随机生成密钥的`.env`配置文件
4. 创建虚拟环境并安装依赖(如果指定`--create-venv`)

## 依赖管理

工具会创建一个包含所有运行FastAPI项目所需依赖的backend目录。项目中的`requirements.txt`文件主要用于:

1. Docker构建时使用
2. 作为项目依赖参考文档
3. 如需在虚拟环境中单独安装

## 项目结构

创建的项目具有以下结构：

```
backend/            # 后端代码
├── app.py          # 应用入口点
├── requirements.txt# 依赖文件（参考和Docker用）
├── Dockerfile      # Docker配置
├── entrypoint.sh   # Docker入口脚本
├── alembic.ini     # 数据库迁移配置
└── src/            # 源代码
    ├── api/        # API路由与控制器
    ├── config/     # 配置
    ├── models/     # 数据模型
    ├── repository/ # 数据库交互
    ├── securities/ # 安全相关
    └── utilities/  # 工具函数
```

## 使用创建的项目

1. 如果创建了虚拟环境，激活它：
   ```bash
   # Windows
   venv\Scripts\activate
   
   # Linux/Mac
   source venv/bin/activate
   ```

2. 启动服务：
   ```bash
   python app.py
   ```

3. 访问API文档：[http://localhost:8000/docs](http://localhost:8000/docs)
django-autokit 0.2.1
A CLI tool to automate Django project setup, including settings splitting, .env creation, and app boilerplate.
License: MIT
Requires Python: >=3.7

# Django Autokit

**Django Autokit** is a CLI tool that automates the setup and maintenance of Django projects. It simplifies common tasks like environment variable setup, splitting settings into `base.py`, `dev.py`, and `prod.py`, generating `.env` files, and creating boilerplate apps — saving you time and effort when starting or scaling projects.

---

## ✨ Features

- 📁 Split `settings.py` into `base.py`, `dev.py`, and `prod.py`
- 🔐 Auto-generate a `.env` with `SETTINGS_PATH` and `ENV` variables
- 🧠 Automatically add new apps to `INSTALLED_APPS` (supports both flat and modular settings)
- 🔄 Compatible with Django 4.x and 5.x

---

## 📦 Installation

```bash
pip install django-autokit
```

---

## 🚀 Usage

Once installed, use the `djkit` CLI tool to run commands.

To see all available commands:

```bash
djkit --help
```

### 1️⃣ Initialize Autokit

In the root of your Django project, run:

```bash
djkit init-env
```

This will:

- Create a `.env` file if it doesn’t exist
- Set the `SETTINGS_PATH` (e.g., `yourproject.settings.base`)
- Add `ENV=dev` with a comment explaining how to switch to production
- Auto-detect and optionally split `settings.py` into modular settings

---

### 2️⃣ Split Settings Manually (Optional)

If not already split, you can do it manually with:

```bash
djkit split-settings
```

This will:

- Move your current `settings.py` into a `settings/` package
- Create `base.py`, `dev.py`, and `prod.py` for better configuration separation

---

### 3️⃣ Create a Django App

To generate a new app and automatically register it in `INSTALLED_APPS`:

```bash
djkit startapp blog
```

This will:

- Run `django-admin startapp blog`
- Automatically insert `'blog'` into your settings (flat or modular)

---

### 4️⃣ Gitignore Generator

To generate a Django-friendly `.gitignore` file:

```bash
djkit gitignore
```


## ⚙️ Environment Management

Your `.env` file will look like this:

```env
# Path to your Django settings file (use base.py for split settings)
SETTINGS_PATH=yourproject.settings.base

# Set ENV to 'prod' when deploying to production
ENV=dev
```

---

## 📁 Example Project Structure

```bash
yourproject/
├── manage.py
├── .env
├── yourproject/
│   ├── settings/
│   │   ├── base.py
│   │   ├── dev.py
│   │   └── prod.py
│   └── __init__.py
├── blog/
│   └── __init__.py
```

---

## ✅ Compatibility

- ✅ Django 4.x
- ✅ Django 5.x
- ✅ Python 3.7+

---

## 🛡 License

This project is licensed under the MIT License – see the [LICENSE](./LICENSE) file for details.

---

## 🤝 Contributing

Pull requests are welcome! If you find a bug or have a feature request, feel free to [open an issue](https://github.com/niyimarc/django_autokit/issues).

See full [Changelog](https://github.com/niyimarc/django_autokit/blob/master/CHANGELOG.md).