Skip to content

Commit 6f10bb6

Browse files
authored
Merge pull request #5 from brianobot/dev
Improve Code Readility and Fix issues with Incorrect Project Detail Initialization
2 parents df0241f + 8ca0be2 commit 6f10bb6

File tree

14 files changed

+463
-201
lines changed

14 files changed

+463
-201
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
.env
1+
*.env
22
venv/
3+
dist/
34
*__pycache__*
5+
data.json
6+
publish_2_pypi.sh

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018 The Python Packaging Authority
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# FastAPI Project Gen8
1+
# FastAPI Gen8
22

33
______________________________________________________________
44

@@ -24,18 +24,22 @@ ______________________________________________________________
2424
╚═════╝ ╚══════╝╚═╝ ╚═══╝╚═══╝ ╚════╝
2525
______________________________________________________________
2626

27-
Generate FastAPI Projects in Seconds
27+
Generate FastAPI Projects in Seconds 🚀
2828

2929
## Overview
3030

31-
FastAPI Project Gen8 is a lightweight command-line tool designed to generate clean, structured, production-ready FastAPI project scaffolds at warp speed.
31+
FastAPI Gen8 is a lightweight command-line tool designed to generate clean, structured, production-ready FastAPI project scaffolds at warp speed.
3232
Whether you're spinning up a new microservice or testing a prototype idea, Gen8 gives you a fresh, organized foundation with sensible defaults — so you can focus on building, not boring setup rituals.
3333

34+
3435
### Prerequisites
3536

3637
Before igniting the generator, make sure you've completed the following:
3738

3839
- Create a remote Git repository for your new project.
40+
- Optionally Setup a Database (E.g, Postgres, MySQL) for your Fastapi
41+
- Setup a Redis Server running on your machine
42+
3943

4044
Gen8 will automatically initialize Git and link your project to the remote origin you provide.
4145
(Think of it as handing the newborn project its first passport.)
@@ -50,7 +54,7 @@ Gen8 will automatically initialize Git and link your project to the remote origi
5054

5155
Installation
5256
```bash
53-
pip install fastapi-project-gen8
57+
pip install fastapi-gen8
5458
```
5559

5660
(or whatever installation method your tool uses — adjust as needed.)
@@ -59,6 +63,8 @@ Usage
5963
```bash
6064
fastapi-gen8
6165
```
66+
![Introduction Screenshot](images/intro_demo.png)
67+
6268

6369
You’ll be prompted for project details such as name, slug, description, and Git remote URL.
6470
Then—whoosh!—a fully structured FastAPI project appears in your universe.
@@ -69,15 +75,29 @@ fastapi-gen8 --name "my-awesome-api" --remote "git@github.com:me/my-awesome-api.
6975
#### Project Structure
7076
A typical generated project looks like:
7177

72-
my-awesome-api/
78+
```
79+
<project_slug_name>/
7380
├── app/
7481
│ ├── main.py
7582
│ ├── routers/
76-
│ └── core/
83+
│ ├── models/
84+
│ ├── services/
85+
│ ├── __init__.py
86+
│ ├── main.py
87+
│ ├── api_router.py
88+
│ ├── dependencies.py
89+
│ ├── logger.py
90+
│ ├── middlewares.py
91+
│ ├── mailer.py
92+
│ ├── redis_manager.py
93+
│ └── utils
7794
├── requirements.txt
95+
├── alembic/
96+
├── alembic.ini
7897
├── .gitignore
7998
├── README.md
8099
└── ...
100+
```
81101

82102
## Why FastAPI Gen8?
83103

@@ -86,4 +106,4 @@ my-awesome-api/
86106
- Because momentum matters — and FastAPI Gen8 gives you that first push.
87107

88108
## License
89-
- MIT License
109+
- [MIT License](LICENSE)

images/intro_demo.png

268 KB
Loading

local_build_and_install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
python3 -m build
2+
3+
pip install -e .
4+

pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[build-system]
2+
requires = ["hatchling >= 1.26"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "fastapi-gen8"
7+
version = "0.0.6"
8+
authors = [
9+
{ name="Brian Obot", email="brianobot9@gmail.com" },
10+
]
11+
description = "FastAPI Project Gen8 is a lightweight command-line tool designed to generate clean, structured, production-ready FastAPI project scaffolds at warp speed"
12+
readme = "README.md"
13+
requires-python = ">=3.9"
14+
classifiers = [
15+
"Programming Language :: Python :: 3",
16+
"Operating System :: OS Independent",
17+
]
18+
license = "MIT"
19+
license-files = ["LICEN[CS]E*"]
20+
21+
[project.urls]
22+
Homepage = "https://github.com/brianobot/fastapi-project-gen8"
23+
Issues = "https://github.com/brianobot/fastapi-project-gen8/issues"
24+
25+
[project.scripts]
26+
fastapi-gen8 = "fastapi_gen8.main:main"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
faker

src/fastapi_gen8/__init__.py

Whitespace-only changes.

src/fastapi_gen8/helpers.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import subprocess
2+
3+
4+
def display_intro_text() -> None:
5+
"""
6+
Displays the Introduction Text of the Library as a Nice and Friendly UI
7+
Alongside a short instructions on how to use the library for new users.
8+
"""
9+
intro_message = """
10+
______________________________________________________________
11+
12+
███████╗ █████╗ ███████╗████████╗ █████╗ ██████╗ ██╗
13+
██╔════╝██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║
14+
█████╗ ███████║███████╗ ██║ ███████║██████╔╝██║
15+
██╔══╝ ██╔══██║╚════██║ ██║ ██╔══██║██ ██║
16+
██║ ██║ ██║███████║ ██║ ██║ ██║██║ ║██║
17+
╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚╝╚╝
18+
19+
██████╗ ██████╗ ██████╗ ███████╗███████╗ ██████ ████████╗
20+
██╔══██╗██╔══██╗██╔═══██╗ ════██╗██╔════╝██╔════╝ ╚══██╔══╝
21+
██████╔╝██████╔╝██║ ██║ ██║█████╗ ██║ ██║
22+
██╔═══╝ ██╔══██╗██║ ██║███ ██║██╔══╝ ██║ ██║
23+
██║ ██║ ██║╚██████╔╝██████╔╝███████╗╚██████╗ ██║
24+
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝
25+
26+
██████╗ ███████╗███╗ ██╗ █████╗
27+
██╔════╝ ██╔════╝████╗ ██║██╔══██╗
28+
██║ ███╗█████╗ ██╔██╗ ██║ █████╔╝
29+
██║ ██║██╔══╝ ██║╚██╗██║██╔══██╗
30+
╚██████╔╝███████╗██║ ╚████║ █████╔╝
31+
╚═════╝ ╚══════╝╚═╝ ╚╝ ╚════╝
32+
______________________________________________________________
33+
"""
34+
print(intro_message)
35+
description = """
36+
Generate a fully structured FastAPI projects instantly.
37+
Boilerplate code, ready-to-run endpoints, and project scaffolding
38+
all in one simple command. Kickstart your backend in seconds!
39+
40+
Provide Project Details to each prompt and press 'Enter' to complete project setup
41+
42+
NOTES: Values placed within square brackets ([My Awesome FastAPI Project]) are defaults values for the project details
43+
If you do not provide a value for any particular, those values are used instead.
44+
45+
Have a Blast 🚀 - Brian
46+
_____________________________________________________________________________________________________
47+
"""
48+
# FUN 🚀
49+
50+
# How Fast Can you Complete your FastAPI project setup?
51+
# Blaze through the steps to make the global leaderboard for projects generated with FastAPI Project Gen8.
52+
# In Order to qualify for this leaderboard, you have to make sure to input every project detail and not use defaults
53+
# even though the defaults match your project attribute.
54+
# Current Best Record: {get_current_best_record()[0]} seconds - Title: [{get_current_best_record()[1]}]
55+
print(description)
56+
57+
58+
def slugify(text: str) -> str:
59+
return text.replace(" ", "_").replace("-", "_").lower()
60+
61+
def success_print(value: str):
62+
print("\033[92m{}\033[00m".format(value))
63+
64+
def warning_print(value: str):
65+
print("\033[33m{}\033[00m".format(value))
66+
67+
def error_print(value: str):
68+
print("\033[31m{}\033[00m".format(value))
69+
70+
71+
def clone_repository(repository_url: str, folder_name: str):
72+
try:
73+
clone_template_repo = subprocess.Popen(["git", "clone", repository_url, folder_name])
74+
clone_template_repo.wait()
75+
except Exception as err:
76+
error_print(f"Failed to Download Template: Reason: {err}")
77+
exit(1)
78+
79+

0 commit comments

Comments
 (0)