Skip to content

Commit 9010d2d

Browse files
committed
📝 Update Readme
1 parent bc49ac3 commit 9010d2d

File tree

6 files changed

+138
-0
lines changed

6 files changed

+138
-0
lines changed

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# FastAPI React MongoDB - Base Project Generator
2+
3+
[![test](https://github.com/ajthr/fastapi-react-mongodb/actions/workflows/test.yml/badge.svg)](https://github.com/ajthr/fastapi-react-mongodb/actions/workflows/test.yml)
4+
5+
<div>
6+
<img src="assets/fastapi-logo.png" alt="fastapi-logo" height="60" /> <img
7+
src="assets/react-logo.png" alt="react-logo" height="60" /> &nbsp; &nbsp; <img
8+
src="assets/typescript-logo.png" alt="typescript-logo" height="60" /> &nbsp;&nbsp;&nbsp;
9+
<img src="assets/mongodb-logo.png" alt="mongodb-logo" height="60" />
10+
</div>
11+
12+
## Features
13+
14+
- **[FastAPI](https://fastapi.tiangolo.com/)** (Python 3.8)
15+
- JWT authentication using [OAuth2 "password
16+
flow"](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/) and
17+
PyJWT
18+
- **[React](https://reactjs.org/)** (with Typescript)
19+
- [react-router v5](https://reacttraining.com/react-router/) to handle routing
20+
- **[MongoDB](https://www.mongodb.com/)** for the database
21+
- **[PyMongo](https://pymongo.readthedocs.io/)** for ODM
22+
- **[Pytest](https://docs.pytest.org/en/latest/)** for backend tests.
23+
- **[Docker Compose](https://docs.docker.com/compose/)** for development
24+
- **[Nginx](https://www.nginx.com/)** as a reverse proxy to allow
25+
backend/frontend on the same port
26+
27+
## Quick Start
28+
29+
First, install cookiecutter if you don't already have it:
30+
31+
```bash
32+
pip3 install cookiecutter
33+
```
34+
35+
Second, install docker-compose if you don't already have it:
36+
37+
[docker-compose installation official
38+
docs](https://docs.docker.com/compose/install/).
39+
40+
Then, in the directory you want your project to live:
41+
42+
```bash
43+
cookiecutter gh:ajthr/fastapi-react-mongodb
44+
```
45+
46+
<details><summary>Input Variables</summary>
47+
48+
- project_name [default fastapi-react-mongodb]
49+
- project_slug [default fastapi-react-mongodb] - this is your project directory
50+
- external_database [default n] - whether to use any external database like mongodb atlas
51+
- external_db_uri [optional default None] - database uri to connect to external database if using one.
52+
- mongodb_user [default root]
53+
- mongodb_password [default password]
54+
- secret_key [default super_secret]
55+
56+
</details>
57+
58+
## Develop
59+
60+
Change into your project directory and run:
61+
62+
```bash
63+
docker-compose build
64+
```
65+
66+
This will build and run the docker containers.
67+
68+
It may take a while to build the first time it's run since it needs to fetch all
69+
the docker images.
70+
71+
Once you've built the images once, you can simply use regular `docker-compose`
72+
commands to manage your development environment, for example to start your
73+
containers:
74+
75+
```bash
76+
docker-compose up -d
77+
```
78+
79+
Once this finishes you can navigate to the localhost port, you should see the slightly modified create-react-app page.
80+
81+
## Testing
82+
83+
To run test for the template, run:
84+
85+
```bash
86+
chmod +x ./test.sh
87+
./test.sh
88+
```
89+
90+
To run test for api, run
91+
```bash
92+
docker-compose run --rm api sh -c "pytest"
93+
```
94+
95+
to run test for web, run
96+
```bash
97+
docker-compose run --rm web sh -c "npm run test"
98+
```

assets/fastapi-logo.png

17.3 KB
Loading

assets/mongodb-logo.png

41.1 KB
Loading

assets/react-logo.png

77.6 KB
Loading

assets/typescript-logo.png

18.1 KB
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# {{cookiecutter.project_name}}
2+
3+
## Development
4+
5+
The only dependencies for this project should be docker and docker-compose.
6+
7+
### Quick Start
8+
9+
Starting the project with hot-reloading enabled
10+
(the first time it will take a while):
11+
12+
```bash
13+
docker-compose up -d
14+
```
15+
16+
And navigate to http://localhost/
17+
18+
### Rebuilding containers:
19+
20+
```
21+
docker-compose build
22+
```
23+
24+
### Bringing containers down:
25+
26+
```
27+
docker-compose down
28+
```
29+
30+
## Testing
31+
32+
To run test for api, run
33+
```bash
34+
docker-compose run --rm api sh -c "pytest"
35+
```
36+
37+
to run test for web, run
38+
```bash
39+
docker-compose run --rm web sh -c "npm run test"
40+
```

0 commit comments

Comments
 (0)