You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 8, 2024. It is now read-only.
Update backend runtime, backend-frontend connection, and console output
- Change 'API_URL' to a specific localhost port for simplicity and rename it for clarity
- Add 'update me' not to backend 'settings.py' for clarity
- Update docstring for 'ExampleDB' in backend for clarity
- Refactor backend 'build.py' -> 'start.py' and move into project for 'app' directory for Poetry script configuration
- Add details in console, after project build, to inform next steps
- Update backend run command to 'app-start'
- Update README
This tool is intended to be dynamic and installs the most recent packages where possible, while maintaining compatibility across the main OS's (Mac, Linux and Windows). You can use the tool by installing the `PIP` package. See the [Using The Tool section](#using-the-tool) for more details.
5
+
Welcome to the quickstart tool for creating a `FastAPI` project with a `NextJS` frontend.
6
6
7
-
If there are any issues using the tool, please flag them in the [issues](https://github.com/Achronus/create-api-app/issues) section of this repository.
7
+
This tool creates a predefined template while installing the most recent packages where possible.
Creating a project from scratch can be a tedious process. Not only do you have to create all the files yourself, it typically requires a lot of small minor changes that can easily be automated. So, rather than wasting a lot of time setting up projects, I created a tool that does it all for me!
@@ -24,6 +33,7 @@ All projects are created using the same stack, consisting of the following:
24
33
1. Backend
25
34
26
35
-[FastAPI](https://github.com/tiangolo/fastapi)
36
+
-[Pydantic](https://docs.pydantic.dev/)
27
37
-[MongoDB](https://www.mongodb.com/)
28
38
-[Beanie](https://beanie-odm.dev/)
29
39
-[Poetry](https://python-poetry.org/)
@@ -42,26 +52,78 @@ All projects are created using the same stack, consisting of the following:
42
52
43
53
_Note: all libraries and packages are automatically installed to their latest versions when running the tool._
We've also added some extra files too! You can find out more about them in our [documentation](https://create.achronus.dev/file-structure/).
50
56
51
-
## Using The Tool
57
+
## Installation
52
58
53
59
1. Firstly, install [Docker](https://docs.docker.com/get-docker/), we use this to create the frontend files dynamically using the [Build NextJS App Tool](https://github.com/Achronus/build-nextjs-app).
54
60
55
-
2. Install the package through `PIP` using the following command (requires `Python 3.12` minimum):
61
+
2. Install the package through `PIP`:
56
62
57
63
```python
58
64
pip install create_api_app
59
65
```
60
66
61
-
3. Create a project with the following command:
67
+
3. Create a project:
62
68
63
69
```python
64
70
create-api-app <project_name>
65
71
```
66
72
67
73
And that's it! You'll find two folders in your project, one called `frontend` (for NextJS) and another called `backend` (for FastAPI).
74
+
75
+
## Running The Backend
76
+
77
+
1. Open a terminal and navigate to the `backend` directory:
78
+
79
+
```cmd
80
+
cd backend
81
+
```
82
+
83
+
2. Install a virtual environment for `Poetry`:
84
+
85
+
```cmd
86
+
python -m venv env
87
+
```
88
+
89
+
3. Access it using one of the following (first -> `Windows`; second -> `Mac/Linux`):
90
+
91
+
```cmd
92
+
.\env\Scripts\activate
93
+
```
94
+
95
+
```cmd
96
+
source ./env/bin/activate
97
+
```
98
+
99
+
_Not working? Refer to the [virtual env docs](https://docs.python.org/3/library/venv.html#how-venvs-work)._
100
+
101
+
4. Run the `uvicorn` server using the `Poetry` script:
102
+
103
+
```cmd
104
+
app-start
105
+
```
106
+
107
+
## Running the Frontend
108
+
109
+
1. Open a terminal and navigate to the `frontend` directory:
110
+
111
+
```cmd
112
+
cd frontend
113
+
```
114
+
115
+
2. Install the packages using [Node.js](https://nodejs.org/en):
116
+
117
+
```cmd
118
+
npm install
119
+
```
120
+
121
+
3. Run the development server:
122
+
123
+
```cmd
124
+
npm run dev
125
+
```
126
+
127
+
## Customization
128
+
129
+
Customization options are found in our [documentation](https://create.achronus.dev/customization/).
from .conf.constants.filepathsimportset_project_name
13
+
from .conf.constants.filepathsimportProjectPaths, set_project_name
13
14
from .setupimportrun_frontend_tasks, run_tasks
14
15
from .utils.helperimportstrip_whitespace_and_dashes
15
16
from .utils.printablesimportproject_table, project_complete_panel
@@ -134,7 +135,17 @@ def main(
134
135
# End of script
135
136
console.print(project_complete_panel())
136
137
console.print(
137
-
f"Access the project files here [link={os.getcwd()}]{name_print}[/link]\n"
138
+
f"Access the project files here [link={os.getcwd()}]{name_print}[/link]"
139
+
)
140
+
141
+
project_paths=ProjectPaths(name)
142
+
console.print(
143
+
textwrap.dedent(f"""
144
+
[dark_goldenrod]Not sure where to start?[/dark_goldenrod]
145
+
- [green][link={project_paths.ENV_LOCAL}].env.local[/link][/green] - Update your API keys
146
+
- [yellow][link={project_paths.SETTINGS}]config/settings.py[/link][/yellow] - Update the [yellow]DB_NAME[/yellow] and [yellow]DB_COLLECTION_NAME[/yellow] for your [green]MongoDB[/green] database
147
+
- [yellow][link={project_paths.MODELS}]models/__init__.py[/link][/yellow] - Update the [green]ExampleDB[/green] model\n
0 commit comments