Skip to content

Commit e7d4266

Browse files
committed
SQLModel added
1 parent 5847cd6 commit e7d4266

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2086
-4
lines changed

FastAPIMongoEngineGraphQL/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from setuptools import setup
22

33
setup(
4-
name='FastAPIMongoEngine',
4+
name='FastAPIMongoEngineGraphQL',
55
version='0.0.1',
66
author='scionoftech',
7-
description='FastAPIMongoEngine is a simple Python API Application',
7+
description='FastAPIMongoEngineGraphQL is a simple Python API Application',
88
platforms='any',
99
install_requires=[
1010
'fastapi',

FastAPISQLAlchamyGraphQL/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from setuptools import setup
22

33
setup(
4-
name='FastAPISQLAlchemy',
4+
name='FastAPISQLAlchemyGraphQL',
55
version='0.0.1',
66
author='scionoftech',
7-
description='FastAPISQLAlchemy is a simple Python API Application',
7+
description='FastAPISQLAlchemyGraphQL is a simple Python API Application',
88
platforms='any',
99
install_requires=[
1010
'fastapi',

FastAPISQLModel/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
2+
3+
COPY app /app
4+
5+
RUN ls -l
6+
7+
# RUN apt-get install python3-psycopg2
8+
9+
RUN pip install -r ./requirements.txt

FastAPISQLModel/Jenkinsfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
pipeline {
2+
agent any
3+
stages {
4+
stage('Clone Repository') {
5+
/* Cloning the repository to our workspace */
6+
steps {
7+
checkout scm
8+
}
9+
}
10+
stage('Build Image') {
11+
steps {
12+
sh 'sudo docker-compose build'
13+
}
14+
}
15+
stage('Run Container') {
16+
steps {
17+
sh 'sudo docker-compose up -d'
18+
}
19+
}
20+
}
21+
}

FastAPISQLModel/README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# FastAPI-SQLModel
2+
3+
FastAPI-SQLModel is a Python API Application with FastAPI, JWT Authentication,
4+
Postgresql, SQLModel, Docker and Jenkins Pipeline
5+
6+
## Features
7+
8+
* Full **Docker** integration (Docker based).
9+
* **Production ready** Python web server using Uvicorn and Gunicorn.
10+
* Python <a href="https://github.com/tiangolo/fastapi" class="external-link" target="_blank">**FastAPI**</a> backend:
11+
* **Fast**: Very high performance, on par with **NodeJS** and **Go** (thanks to Starlette and Pydantic).
12+
* **Intuitive**: Great editor support. <abbr title="also known as auto-complete, autocompletion, IntelliSense">Completion</abbr> everywhere. Less time debugging.
13+
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
14+
* **Short**: Minimize code duplication. Multiple features from each parameter declaration.
15+
* **Robust**: Get production-ready code. With automatic interactive documentation.
16+
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank">OpenAPI</a> and <a href="http://json-schema.org/" class="external-link" target="_blank">JSON Schema</a>.
17+
* <a href="https://fastapi.tiangolo.com/features/" class="external-link" target="_blank">**Many other features**</a> including automatic validation, serialization, interactive documentation, authentication with OAuth2 JWT tokens, etc.
18+
* **Secure password** hashing by default.
19+
* **JWT token** authentication.
20+
* **SQLModel** new SQL ORM.
21+
* Basic starting models for users (modify and remove as you need).
22+
* **CORS** (Cross Origin Resource Sharing).
23+
* Load balancing between frontend and backend with **Nginx**, so you can have both under the same domain, separated by path, but served by different containers.
24+
* Let's Encrypt **HTTPS** certificates automatic generation.
25+
26+
27+
## How to use it
28+
29+
**psycopg2**
30+
31+
psycopg2 is postgresql adapter for sqlalchamy this can't be installed directly
32+
in linux using pip, use below command to install
33+
34+
```bash
35+
sudo apt-get install python3-psycopg2
36+
sudo apt-get install libpq-dev python3-dev
37+
```
38+
39+
## JWT token authentication
40+
41+
JWT-Signature using RSA256 algorithm.
42+
43+
You can generate a 2048-bit RSA key pair with the following commands:
44+
45+
```bash
46+
openssl genpkey -algorithm RSA -out rsa_private.pem -pkeyopt rsa_keygen_bits:2048
47+
openssl rsa -in rsa_private.pem -pubout -out rsa_public.pem
48+
```
49+
50+
## Create SSL Certificates using Certbot
51+
52+
Generate SSL cerificates from trusted thirdparty or openssl
53+
54+
For Open SSL use Certbot (Let'sencrypt)
55+
```bash
56+
sudo apt-get update
57+
sudo apt-get install software-properties-common
58+
sudo add-apt-repository universe
59+
sudo add-apt-repository ppa:certbot/certbot
60+
sudo apt-get install certbot python3-certbot-nginx
61+
62+
sudo certbot -d example.com certonly
63+
```
64+
certificates will be found in "/etc/letsencrypt/live/example.com/"
65+
66+
Generate a set of 4096-bit diffie-hellman parameters to improve security for some types of ciphers.
67+
```bash
68+
sudo mkdir -p /etc/nginx/ssl
69+
sudo openssl dhparam -out /etc/nginx/ssl/dhp-4096.pem 4096
70+
```
71+
72+
## Deployment
73+
74+
FastAPI Backend can be deployed using docker. Use below docker image for deployment.
75+
76+
tiangolo/uvicorn-gunicorn-fastapi-docker - [Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python 3.6 and above with performance auto-tuning. Optionally with Alpine Linux.](https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker)
77+
78+
79+
#### References
80+
81+
The fundamental repositories:
82+
- FastAPI - [FastAPI framework, high performance, easy to learn, fast to code, ready for production](https://fastapi.tiangolo.com/)
83+
- full-stack-fastapi-postgresql - [Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Docker, automatic HTTPS and more.](https://github.com/tiangolo/full-stack-fastapi-postgresql)
84+
- blog-posts - [Build a web API from scratch with FastAPI - the workshop](https://github.com/tiangolo/blog-posts/tree/master/pyconby-web-api-from-scratch-with-fastapi)
85+
- uvicorn - [The lightning-fast ASGI server.](https://www.uvicorn.org/deployment/)
86+
- tiangolo/uvicorn-gunicorn-fastapi-docker - [Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python 3.6 and above with performance auto-tuning. Optionally with Alpine Linux.](https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker)
87+
- sqlmodel - [SQLModel is a library for interacting with SQL databases from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust.](https://sqlmodel.tiangolo.com/)
88+
-

FastAPISQLModel/app/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from . import auth
2+
from . import conf
3+
from . import controller
4+
from . import crud
5+
from . import db
6+
from . import logs
7+
from . import routes
8+
from . import util
Binary file not shown.
Binary file not shown.

FastAPISQLModel/app/auth/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .token import access_token
2+
Binary file not shown.

0 commit comments

Comments
 (0)