one-click-drf 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- one_click_drf-0.1.0/PKG-INFO +165 -0
- one_click_drf-0.1.0/README.md +153 -0
- one_click_drf-0.1.0/pyproject.toml +21 -0
- one_click_drf-0.1.0/src/one_click_drf/__init__.py +2 -0
- one_click_drf-0.1.0/src/one_click_drf/cli.py +145 -0
- one_click_drf-0.1.0/src/one_click_drf/config.py +51 -0
- one_click_drf-0.1.0/src/one_click_drf/generator.py +296 -0
- one_click_drf-0.1.0/src/one_click_drf/prompts.py +47 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/DEVELOPMENT_GUIDE.md.jinja +54 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/__init__.py.jinja +1 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/asgi.py.jinja +7 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/erd.sh.jinja +4 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/manage.py.jinja +20 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/nginx.backend.conf.jinja +29 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/requirements/base.txt.jinja +4 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/requirements/dev.txt.jinja +4 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/requirements/prod.txt.jinja +4 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/settings.py.jinja +219 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/urls.py.jinja +62 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/django/wsgi.py.jinja +7 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/docker/.dockerignore.jinja +62 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/docker/Dockerfile.jinja +38 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/docker/docker-compose.dev.yml.jinja +16 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/docker/docker-compose.prod.yml.jinja +11 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/docker/docker-compose.yml.jinja +26 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/docker/docker-helper.sh.jinja +20 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/docker/entrypoint.sh.jinja +32 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/env/.env.jinja +61 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/env/.gitignore.jinja +202 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/github/ci.yml.jinja +34 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/github/pipeline.yml.jinja +52 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/ansible/.gitignore.jinja +11 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/ansible/configure_server.sh.jinja +5 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/ansible/hosts.ini.jinja +2 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/ansible/playbook.yml.jinja +96 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/main.tf.jinja +20 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/terraform/.gitignore.jinja +33 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/terraform/create_infra.sh.jinja +9 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/terraform/destroy_infra.sh.jinja +5 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/terraform/main.tf.jinja +44 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/terraform/outputs.tf.jinja +23 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/terraform/provider.tf.jinja +4 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/terraform/security_groups.tf.jinja +48 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/iac/terraform/variables.tf.jinja +26 -0
- one_click_drf-0.1.0/src/one_click_drf/templates/observability/prometheus.yml.jinja +7 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: one-click-drf
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: One command to generate a production-ready Django REST backend
|
|
5
|
+
Author: Shemanto Sharkar
|
|
6
|
+
Author-email: Shemanto Sharkar <shemantosharkarofficial@gmail.com>
|
|
7
|
+
Requires-Dist: jinja2>=3.1.6
|
|
8
|
+
Requires-Dist: rich>=14.3.2
|
|
9
|
+
Requires-Dist: typer>=0.21.1
|
|
10
|
+
Requires-Python: >=3.12
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
<a name="top"></a>
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
# One Click DRF (OCD) 🚀
|
|
17
|
+
|
|
18
|
+
> **বাংলায় README ফাইলটি পড়ে দেখুন [এখানে (README.bn.md)](./README.bn.md)**
|
|
19
|
+
|
|
20
|
+
**One Click DRF** is a powerful CLI tool designed to bootstrap **production-ready** Django REST Framework projects in seconds.
|
|
21
|
+
|
|
22
|
+
[](https://pypi.org/project/one-click-drf/)
|
|
23
|
+
[](https://pypi.org/project/one-click-drf/)
|
|
24
|
+
[](https://github.com/shemanto27/One-Click-Production-Ready-Django-Backend-Setup/blob/main/LICENSE)
|
|
25
|
+
[](https://github.com/shemanto27/One-Click-Production-Ready-Django-Backend-Setup)
|
|
26
|
+
|
|
27
|
+
### 🛠️ Technology Stack
|
|
28
|
+
[](https://python.org)
|
|
29
|
+
[](https://djangoproject.com)
|
|
30
|
+
[](https://docker.com)
|
|
31
|
+
[](https://terraform.io)
|
|
32
|
+
[](https://ansible.com)
|
|
33
|
+
[](https://github.com/features/actions)
|
|
34
|
+
[](https://prometheus.io)
|
|
35
|
+
[](https://grafana.com)
|
|
36
|
+
|
|
37
|
+
⭐ **Star us on GitHub** — your support motivates us a lot! 🙏😊
|
|
38
|
+
|
|
39
|
+
[](https://www.linkedin.com/in/shemanto/)
|
|
40
|
+
[](https://www.linkedin.com/sharing/share-offsite/?url=https://github.com/shemanto27/One-Click-Production-Ready-Django-Backend-Setup)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
Stop copy-pasting code from old projects. Start with a solid foundation.
|
|
45
|
+
|
|
46
|
+
## 🌟 The Story Behind One Click DRF
|
|
47
|
+
Every time a new project starts at the office, I see a familiar cycle: developers need to start everything from scratch, from ground zero, through repetitive and manual work like this:
|
|
48
|
+
- **Repetitive Installations:** Manually installing `djangorestframework`, `django-cors-headers`, `drf-yasg(Swagger)`, and other essential packages every single time.
|
|
49
|
+
- **Settings Fatigue:** Manually tweaking settings, creating `.env` files, and mapping them to variables.
|
|
50
|
+
- **The Hunt:** Going to GitHub just to find a standard Python `.gitignore`.
|
|
51
|
+
- **Human Error:** Forgetting something critical—like CORS settings—only to realize it hours later when the frontend developer can't connect.
|
|
52
|
+
- **Confidence Gap:** Even after hours of setup, no one is 100% sure if the environment is truly "perfect" or "production-ready."
|
|
53
|
+
|
|
54
|
+
**One Click DRF** was born to solve this. It automates these repetitive tasks and guarantees a battle-tested, production-ready foundation in **seconds**. No more copy-pasting, no more forgotten settings—just one command to start building what actually matters.
|
|
55
|
+
|
|
56
|
+
## 🚀 What you get with `ocd`
|
|
57
|
+
When you initialize a project with `ocd`, you’re not just getting a folder—you’re getting a full production environment:
|
|
58
|
+
- **🐳 Docker Ready:** Multi-stage `Dockerfile` and `docker-compose.yml` for development and production.
|
|
59
|
+
- **⚙️ CI/CD (GitHub Actions):** Pre-configured workflows for automated testing, linting, and deployment.
|
|
60
|
+
- **🏗️ Infrastructure as Code (IaC):** Terraform templates to manage your cloud resource effortlessly.
|
|
61
|
+
- **☁️ AWS Deployment Ready:** Built-in configurations to deploy your backend to AWS with confidence.
|
|
62
|
+
- **📊 Monitoring & Observability:** Integrated Prometheus and Grafana setup to keep an eye on your app's health.
|
|
63
|
+
- **🛠️ Production Settings & .env:** Professionally split `settings.py` and automatically generated `.env` file.
|
|
64
|
+
- **📝 Swagger API Ready:** Instant API documentation with `drf-yasg` so you're ready to test immediately.
|
|
65
|
+
- **📂 Organized Apps Folder:** A clean architecture where all your Django apps live in a dedicated `apps/` directory.
|
|
66
|
+
- **🔒 Standard .gitignore:** A pre-configured, standard Python `.gitignore` so you don't have to find one.
|
|
67
|
+
- **🚀 GitHub Integration:** Option to automatically initialize a git repo and push to a new GitHub repository in one go.
|
|
68
|
+
|
|
69
|
+
## 📦 Installation
|
|
70
|
+
|
|
71
|
+
Since **one-click-drf** is a CLI tool, it is recommended to install it globally using `uv`:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
uv tool install one-click-drf
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
If your system doesn't have `uv` yet, follow the [installation guide here](https://docs.astral.sh/uv/getting-started/installation/).
|
|
78
|
+
|
|
79
|
+
Alternatively, you can use pip:
|
|
80
|
+
```bash
|
|
81
|
+
pip install one-click-drf
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 🚀 Usage
|
|
85
|
+
|
|
86
|
+
### Initialize a new project
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
ocd init myproject
|
|
90
|
+
```
|
|
91
|
+
This creates a new folder `myproject` with a production-ready structure.
|
|
92
|
+
|
|
93
|
+
### Initialize in current directory
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
ocd init .
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Enable Optional Features
|
|
100
|
+
|
|
101
|
+
You can mix and match flags:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
ocd init myproject --docker --ci-cd
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Or enable everything:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
ocd init myproject --all
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## 🚩 CLI Flags
|
|
114
|
+
|
|
115
|
+
| Flag | Description |
|
|
116
|
+
|------|-------------|
|
|
117
|
+
| `--docker` | Adds `Dockerfile` and `docker-compose.yml` |
|
|
118
|
+
| `--ci-cd` | Adds GitHub Actions workflow for testing & linting |
|
|
119
|
+
| `--iac` | Adds Terraform skeleton for AWS |
|
|
120
|
+
| `--observability` | Adds Prometheus configuration |
|
|
121
|
+
| `--all` | Enables all above features |
|
|
122
|
+
|
|
123
|
+
## 📂 Project Structure
|
|
124
|
+
|
|
125
|
+
We follow a clean, modular structure where the Django backend is isolated in its own directory, and infrastructure/deployment files are organized at the root:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
project-root/
|
|
129
|
+
├── backend/ # Django backend source code
|
|
130
|
+
│ ├── core/ # Project configuration (settings.py, urls.py, etc.)
|
|
131
|
+
│ ├── apps/ # Your Django apps live here
|
|
132
|
+
│ ├── manage.py # Django management CLI
|
|
133
|
+
│ ├── .env # Environment variables
|
|
134
|
+
│ ├── .gitignore # Backend-specific ignore rules
|
|
135
|
+
│ ├── Dockerfile # Backend container definition
|
|
136
|
+
│ ├── erd.sh # ERD generation utility
|
|
137
|
+
│ └── requirements/ # Dependencies split (base, dev, prod)
|
|
138
|
+
├── nginx/ # Nginx proxy configuration
|
|
139
|
+
├── .github/ # CI/CD (GitHub Actions workflows)
|
|
140
|
+
├── infra/ # Infrastructure as Code (Terraform & Ansible)
|
|
141
|
+
├── monitoring/ # Observability (Prometheus/Grafana)
|
|
142
|
+
├── docker-compose.yml # Root orchestration for all services
|
|
143
|
+
└── DEVELOPMENT_GUIDE.md # Detailed guide to get started
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 🚀 Built for the Future (Extensibility)
|
|
147
|
+
This structure is intentionally designed for scaling into a full-stack or microservices architecture:
|
|
148
|
+
- **Full-Stack Ready**: Need a frontend? Simply add a `frontend/` folder (React, Next.js, Vue, etc.) at the root.
|
|
149
|
+
- **Microservices/AI Ready**: You can easily plug in other services like `ml-service/` or `ai-apps/` in their own folders next to the backend.
|
|
150
|
+
- **Simplified Orchestration**: Any new service can be integrated into the root `docker-compose.yml` and CI/CD pipelines, ensuring your entire ecosystem remains easy to deploy in the cloud.
|
|
151
|
+
|
|
152
|
+
## 🤝 Contribution
|
|
153
|
+
|
|
154
|
+
We welcome contributions!
|
|
155
|
+
1. Fork the repo.
|
|
156
|
+
2. Clone it clearly.
|
|
157
|
+
3. Install dependencies: `uv sync` or `pip install -e .`
|
|
158
|
+
4. Add a new generator in `one_click_drf/generators.py` or new templates in `one_click_drf/templates/`.
|
|
159
|
+
|
|
160
|
+
## ⚙️ Configuration
|
|
161
|
+
|
|
162
|
+
On first run, `ocd` will ask for your GitHub and DockerHub usernames. These are saved in `~/.config/one-click-drf/config.toml` so you don't have to type them again.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
[Back to Top](#top)
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<a name="top"></a>
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
# One Click DRF (OCD) 🚀
|
|
5
|
+
|
|
6
|
+
> **বাংলায় README ফাইলটি পড়ে দেখুন [এখানে (README.bn.md)](./README.bn.md)**
|
|
7
|
+
|
|
8
|
+
**One Click DRF** is a powerful CLI tool designed to bootstrap **production-ready** Django REST Framework projects in seconds.
|
|
9
|
+
|
|
10
|
+
[](https://pypi.org/project/one-click-drf/)
|
|
11
|
+
[](https://pypi.org/project/one-click-drf/)
|
|
12
|
+
[](https://github.com/shemanto27/One-Click-Production-Ready-Django-Backend-Setup/blob/main/LICENSE)
|
|
13
|
+
[](https://github.com/shemanto27/One-Click-Production-Ready-Django-Backend-Setup)
|
|
14
|
+
|
|
15
|
+
### 🛠️ Technology Stack
|
|
16
|
+
[](https://python.org)
|
|
17
|
+
[](https://djangoproject.com)
|
|
18
|
+
[](https://docker.com)
|
|
19
|
+
[](https://terraform.io)
|
|
20
|
+
[](https://ansible.com)
|
|
21
|
+
[](https://github.com/features/actions)
|
|
22
|
+
[](https://prometheus.io)
|
|
23
|
+
[](https://grafana.com)
|
|
24
|
+
|
|
25
|
+
⭐ **Star us on GitHub** — your support motivates us a lot! 🙏😊
|
|
26
|
+
|
|
27
|
+
[](https://www.linkedin.com/in/shemanto/)
|
|
28
|
+
[](https://www.linkedin.com/sharing/share-offsite/?url=https://github.com/shemanto27/One-Click-Production-Ready-Django-Backend-Setup)
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
Stop copy-pasting code from old projects. Start with a solid foundation.
|
|
33
|
+
|
|
34
|
+
## 🌟 The Story Behind One Click DRF
|
|
35
|
+
Every time a new project starts at the office, I see a familiar cycle: developers need to start everything from scratch, from ground zero, through repetitive and manual work like this:
|
|
36
|
+
- **Repetitive Installations:** Manually installing `djangorestframework`, `django-cors-headers`, `drf-yasg(Swagger)`, and other essential packages every single time.
|
|
37
|
+
- **Settings Fatigue:** Manually tweaking settings, creating `.env` files, and mapping them to variables.
|
|
38
|
+
- **The Hunt:** Going to GitHub just to find a standard Python `.gitignore`.
|
|
39
|
+
- **Human Error:** Forgetting something critical—like CORS settings—only to realize it hours later when the frontend developer can't connect.
|
|
40
|
+
- **Confidence Gap:** Even after hours of setup, no one is 100% sure if the environment is truly "perfect" or "production-ready."
|
|
41
|
+
|
|
42
|
+
**One Click DRF** was born to solve this. It automates these repetitive tasks and guarantees a battle-tested, production-ready foundation in **seconds**. No more copy-pasting, no more forgotten settings—just one command to start building what actually matters.
|
|
43
|
+
|
|
44
|
+
## 🚀 What you get with `ocd`
|
|
45
|
+
When you initialize a project with `ocd`, you’re not just getting a folder—you’re getting a full production environment:
|
|
46
|
+
- **🐳 Docker Ready:** Multi-stage `Dockerfile` and `docker-compose.yml` for development and production.
|
|
47
|
+
- **⚙️ CI/CD (GitHub Actions):** Pre-configured workflows for automated testing, linting, and deployment.
|
|
48
|
+
- **🏗️ Infrastructure as Code (IaC):** Terraform templates to manage your cloud resource effortlessly.
|
|
49
|
+
- **☁️ AWS Deployment Ready:** Built-in configurations to deploy your backend to AWS with confidence.
|
|
50
|
+
- **📊 Monitoring & Observability:** Integrated Prometheus and Grafana setup to keep an eye on your app's health.
|
|
51
|
+
- **🛠️ Production Settings & .env:** Professionally split `settings.py` and automatically generated `.env` file.
|
|
52
|
+
- **📝 Swagger API Ready:** Instant API documentation with `drf-yasg` so you're ready to test immediately.
|
|
53
|
+
- **📂 Organized Apps Folder:** A clean architecture where all your Django apps live in a dedicated `apps/` directory.
|
|
54
|
+
- **🔒 Standard .gitignore:** A pre-configured, standard Python `.gitignore` so you don't have to find one.
|
|
55
|
+
- **🚀 GitHub Integration:** Option to automatically initialize a git repo and push to a new GitHub repository in one go.
|
|
56
|
+
|
|
57
|
+
## 📦 Installation
|
|
58
|
+
|
|
59
|
+
Since **one-click-drf** is a CLI tool, it is recommended to install it globally using `uv`:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
uv tool install one-click-drf
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
If your system doesn't have `uv` yet, follow the [installation guide here](https://docs.astral.sh/uv/getting-started/installation/).
|
|
66
|
+
|
|
67
|
+
Alternatively, you can use pip:
|
|
68
|
+
```bash
|
|
69
|
+
pip install one-click-drf
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 🚀 Usage
|
|
73
|
+
|
|
74
|
+
### Initialize a new project
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
ocd init myproject
|
|
78
|
+
```
|
|
79
|
+
This creates a new folder `myproject` with a production-ready structure.
|
|
80
|
+
|
|
81
|
+
### Initialize in current directory
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
ocd init .
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Enable Optional Features
|
|
88
|
+
|
|
89
|
+
You can mix and match flags:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
ocd init myproject --docker --ci-cd
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Or enable everything:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
ocd init myproject --all
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 🚩 CLI Flags
|
|
102
|
+
|
|
103
|
+
| Flag | Description |
|
|
104
|
+
|------|-------------|
|
|
105
|
+
| `--docker` | Adds `Dockerfile` and `docker-compose.yml` |
|
|
106
|
+
| `--ci-cd` | Adds GitHub Actions workflow for testing & linting |
|
|
107
|
+
| `--iac` | Adds Terraform skeleton for AWS |
|
|
108
|
+
| `--observability` | Adds Prometheus configuration |
|
|
109
|
+
| `--all` | Enables all above features |
|
|
110
|
+
|
|
111
|
+
## 📂 Project Structure
|
|
112
|
+
|
|
113
|
+
We follow a clean, modular structure where the Django backend is isolated in its own directory, and infrastructure/deployment files are organized at the root:
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
project-root/
|
|
117
|
+
├── backend/ # Django backend source code
|
|
118
|
+
│ ├── core/ # Project configuration (settings.py, urls.py, etc.)
|
|
119
|
+
│ ├── apps/ # Your Django apps live here
|
|
120
|
+
│ ├── manage.py # Django management CLI
|
|
121
|
+
│ ├── .env # Environment variables
|
|
122
|
+
│ ├── .gitignore # Backend-specific ignore rules
|
|
123
|
+
│ ├── Dockerfile # Backend container definition
|
|
124
|
+
│ ├── erd.sh # ERD generation utility
|
|
125
|
+
│ └── requirements/ # Dependencies split (base, dev, prod)
|
|
126
|
+
├── nginx/ # Nginx proxy configuration
|
|
127
|
+
├── .github/ # CI/CD (GitHub Actions workflows)
|
|
128
|
+
├── infra/ # Infrastructure as Code (Terraform & Ansible)
|
|
129
|
+
├── monitoring/ # Observability (Prometheus/Grafana)
|
|
130
|
+
├── docker-compose.yml # Root orchestration for all services
|
|
131
|
+
└── DEVELOPMENT_GUIDE.md # Detailed guide to get started
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 🚀 Built for the Future (Extensibility)
|
|
135
|
+
This structure is intentionally designed for scaling into a full-stack or microservices architecture:
|
|
136
|
+
- **Full-Stack Ready**: Need a frontend? Simply add a `frontend/` folder (React, Next.js, Vue, etc.) at the root.
|
|
137
|
+
- **Microservices/AI Ready**: You can easily plug in other services like `ml-service/` or `ai-apps/` in their own folders next to the backend.
|
|
138
|
+
- **Simplified Orchestration**: Any new service can be integrated into the root `docker-compose.yml` and CI/CD pipelines, ensuring your entire ecosystem remains easy to deploy in the cloud.
|
|
139
|
+
|
|
140
|
+
## 🤝 Contribution
|
|
141
|
+
|
|
142
|
+
We welcome contributions!
|
|
143
|
+
1. Fork the repo.
|
|
144
|
+
2. Clone it clearly.
|
|
145
|
+
3. Install dependencies: `uv sync` or `pip install -e .`
|
|
146
|
+
4. Add a new generator in `one_click_drf/generators.py` or new templates in `one_click_drf/templates/`.
|
|
147
|
+
|
|
148
|
+
## ⚙️ Configuration
|
|
149
|
+
|
|
150
|
+
On first run, `ocd` will ask for your GitHub and DockerHub usernames. These are saved in `~/.config/one-click-drf/config.toml` so you don't have to type them again.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
[Back to Top](#top)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "one-click-drf"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "One command to generate a production-ready Django REST backend"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Shemanto Sharkar", email = "shemantosharkarofficial@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.12"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"jinja2>=3.1.6",
|
|
12
|
+
"rich>=14.3.2",
|
|
13
|
+
"typer>=0.21.1",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[build-system]
|
|
17
|
+
requires = ["uv_build>=0.9.16,<0.10.0"]
|
|
18
|
+
build-backend = "uv_build"
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
ocd = "one_click_drf.cli:app"
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from rich.console import Console
|
|
4
|
+
|
|
5
|
+
from one_click_drf.prompts import ask_project_info, ensure_global_config
|
|
6
|
+
from one_click_drf.generator import (
|
|
7
|
+
generate_django_core,
|
|
8
|
+
generate_docker,
|
|
9
|
+
generate_cicd,
|
|
10
|
+
generate_iac,
|
|
11
|
+
generate_observability
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
help_text="""
|
|
15
|
+
Initialize a Production Ready Django REST Framework project in One Click.
|
|
16
|
+
|
|
17
|
+
Made with ❤️ by Shemanto Sharkar
|
|
18
|
+
GitHub: https://github.com/shemanto27
|
|
19
|
+
LinkedIn: https://www.linkedin.com/in/shemanto/
|
|
20
|
+
|
|
21
|
+
Usage:
|
|
22
|
+
one-click-drf init [OPTIONS] [PATH]
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
--all Enable everything
|
|
26
|
+
--docker Include Docker support
|
|
27
|
+
--ci-cd Include GitHub Actions
|
|
28
|
+
--iac Include Terraform/Ansible
|
|
29
|
+
--observability Include Prometheus/Grafana
|
|
30
|
+
--help Show this message and exit
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
one-click-drf init myproject
|
|
34
|
+
one-click-drf init myproject --docker --ci-cd --iac --observability
|
|
35
|
+
one-click-drf init myproject --all
|
|
36
|
+
one-click-drf init myproject --docker --ci-cd --iac --observability --all
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
app = typer.Typer(help=help_text, add_completion=False)
|
|
40
|
+
console = Console()
|
|
41
|
+
|
|
42
|
+
@app.command()
|
|
43
|
+
def init(
|
|
44
|
+
path: Path = typer.Argument(None, help="Project name or path. Use '.' for current directory.", show_default=False),
|
|
45
|
+
docker: bool = typer.Option(False, "--docker", help="Include Docker support"),
|
|
46
|
+
ci_cd: bool = typer.Option(False, "--ci-cd", help="Include GitHub Actions"),
|
|
47
|
+
iac: bool = typer.Option(False, "--iac", help="Include Terraform/Ansible"),
|
|
48
|
+
observability: bool = typer.Option(False, "--observability", help="Include Prometheus/Grafana"),
|
|
49
|
+
all_features: bool = typer.Option(False, "--all", help="Enable everything"),
|
|
50
|
+
):
|
|
51
|
+
"""
|
|
52
|
+
Initialize a new production-ready Django project.
|
|
53
|
+
"""
|
|
54
|
+
if all_features:
|
|
55
|
+
docker = ci_cd = iac = observability = True
|
|
56
|
+
|
|
57
|
+
# Ensure config first
|
|
58
|
+
global_config = ensure_global_config()
|
|
59
|
+
|
|
60
|
+
# Determine Project Root and Name
|
|
61
|
+
if path is None:
|
|
62
|
+
# Ask for name, create dir
|
|
63
|
+
info = ask_project_info()
|
|
64
|
+
project_name = info["project_name"]
|
|
65
|
+
project_root = Path.cwd() / project_name
|
|
66
|
+
if project_root.exists() and any(project_root.iterdir()):
|
|
67
|
+
console.print(f"[bold red]❌ Directory {project_name} already exists and is not empty.[/bold red]")
|
|
68
|
+
raise typer.Exit(code=1)
|
|
69
|
+
project_root.mkdir(exist_ok=True)
|
|
70
|
+
elif str(path) == ".":
|
|
71
|
+
# Use current dir
|
|
72
|
+
project_root = Path.cwd()
|
|
73
|
+
# Default name is current dir name
|
|
74
|
+
info = ask_project_info(default_name=project_root.name)
|
|
75
|
+
project_name = info["project_name"]
|
|
76
|
+
else:
|
|
77
|
+
# Path provided (e.g. ./myproject)
|
|
78
|
+
project_root = path.resolve()
|
|
79
|
+
default_name = path.name
|
|
80
|
+
project_root.mkdir(parents=True, exist_ok=True)
|
|
81
|
+
|
|
82
|
+
console.print(f"[dim]Using target directory: {project_root}[/dim]")
|
|
83
|
+
info = ask_project_info(default_name=default_name)
|
|
84
|
+
project_name = info["project_name"]
|
|
85
|
+
|
|
86
|
+
# Merge context
|
|
87
|
+
context = {
|
|
88
|
+
"project_name": project_name.replace(" ", "_").replace("-", "_"), # Safe python name
|
|
89
|
+
"apps": info["apps"],
|
|
90
|
+
"github_username": global_config.get("github_username", ""),
|
|
91
|
+
"dockerhub_username": global_config.get("dockerhub_username", ""),
|
|
92
|
+
"github_repository_url": info.get("github_url", ""),
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.print(f"\n[bold green]🚀 Initializing {project_name} in {project_root}...[/bold green]")
|
|
96
|
+
|
|
97
|
+
# Generate Core (Mandatory)
|
|
98
|
+
with console.status("Generating Django Core & Dependencies...") as status:
|
|
99
|
+
generate_django_core(project_root, context)
|
|
100
|
+
console.print("[green]✓ Django Core generated[/green]")
|
|
101
|
+
|
|
102
|
+
if docker:
|
|
103
|
+
with console.status("Generating Docker files..."):
|
|
104
|
+
generate_docker(project_root, context)
|
|
105
|
+
console.print("[green]✓ Docker files generated[/green]")
|
|
106
|
+
|
|
107
|
+
if ci_cd:
|
|
108
|
+
with console.status("Generating CI/CD workflows..."):
|
|
109
|
+
generate_cicd(project_root, context)
|
|
110
|
+
console.print("[green]✓ CI/CD workflows generated[/green]")
|
|
111
|
+
|
|
112
|
+
if iac:
|
|
113
|
+
with console.status("Generating IaC templates..."):
|
|
114
|
+
generate_iac(project_root, context)
|
|
115
|
+
console.print("[green]✓ IaC templates generated[/green]")
|
|
116
|
+
|
|
117
|
+
if observability:
|
|
118
|
+
with console.status("Generating Observability configs..."):
|
|
119
|
+
generate_observability(project_root, context)
|
|
120
|
+
console.print("[green]✓ Observability configs generated[/green]")
|
|
121
|
+
|
|
122
|
+
# Final Instruction
|
|
123
|
+
console.print("\n[bold green]✨ Project initialized successfully![/bold green]")
|
|
124
|
+
console.print(f"\nNext steps:")
|
|
125
|
+
if str(path) != ".":
|
|
126
|
+
console.print(f" cd {project_root.name if path else project_name}")
|
|
127
|
+
|
|
128
|
+
console.print("\n[bold]Run with Docker:[/bold]")
|
|
129
|
+
console.print(" docker compose -f docker-compose.dev.yml up --build")
|
|
130
|
+
|
|
131
|
+
console.print("\n[bold]Run Locally:[/bold]")
|
|
132
|
+
console.print(" cd backend")
|
|
133
|
+
console.print(" source .venv/bin/activate")
|
|
134
|
+
console.print(" python manage.py runserver")
|
|
135
|
+
|
|
136
|
+
console.print("\n[bold blue]Superuser Created:[/bold blue]")
|
|
137
|
+
console.print(" Email: admin@gmail.com")
|
|
138
|
+
console.print(" Password: admin123")
|
|
139
|
+
|
|
140
|
+
@app.command()
|
|
141
|
+
def version():
|
|
142
|
+
typer.echo("one-click-drf v0.1.0")
|
|
143
|
+
|
|
144
|
+
if __name__ == "__main__":
|
|
145
|
+
app()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import subprocess
|
|
3
|
+
try:
|
|
4
|
+
import tomllib
|
|
5
|
+
except ImportError:
|
|
6
|
+
import toml as tomllib # Fallback if needed, though pyproject says >=3.12
|
|
7
|
+
from typing import Dict, Any, Optional
|
|
8
|
+
|
|
9
|
+
APP_NAME = "one-click-drf"
|
|
10
|
+
CONFIG_DIR = Path.home() / ".config" / APP_NAME
|
|
11
|
+
CONFIG_FILE = CONFIG_DIR / "config.toml"
|
|
12
|
+
|
|
13
|
+
def get_git_user() -> str:
|
|
14
|
+
"""Attempt to get the git global user name."""
|
|
15
|
+
try:
|
|
16
|
+
result = subprocess.run(
|
|
17
|
+
["git", "config", "--global", "user.name"],
|
|
18
|
+
capture_output=True,
|
|
19
|
+
text=True,
|
|
20
|
+
check=False
|
|
21
|
+
)
|
|
22
|
+
return result.stdout.strip()
|
|
23
|
+
except Exception:
|
|
24
|
+
return ""
|
|
25
|
+
|
|
26
|
+
def load_config() -> Dict[str, Any]:
|
|
27
|
+
"""Load configuration from the local config file."""
|
|
28
|
+
if not CONFIG_FILE.exists():
|
|
29
|
+
return {}
|
|
30
|
+
try:
|
|
31
|
+
with open(CONFIG_FILE, "rb") as f:
|
|
32
|
+
return tomllib.load(f)
|
|
33
|
+
except Exception:
|
|
34
|
+
return {}
|
|
35
|
+
|
|
36
|
+
def save_config(github_username: str, dockerhub_username: str):
|
|
37
|
+
"""Save configuration to the local config file."""
|
|
38
|
+
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
39
|
+
|
|
40
|
+
# Simple TOML dumping
|
|
41
|
+
content = f"""[user]
|
|
42
|
+
github_username = "{github_username}"
|
|
43
|
+
dockerhub_username = "{dockerhub_username}"
|
|
44
|
+
"""
|
|
45
|
+
with open(CONFIG_FILE, "w") as f:
|
|
46
|
+
f.write(content)
|
|
47
|
+
|
|
48
|
+
def get_config_value(key: str, default: str = "") -> str:
|
|
49
|
+
"""Get a specific config value from the [user] table."""
|
|
50
|
+
config = load_config()
|
|
51
|
+
return config.get("user", {}).get(key, default)
|