Basic Tiktok clone
- Visitors can only view Post
- User can login or signup
- User can create Posts and Comments
- Post has Comments
docs/conception
: data models- http://localhost:8000/docs : auto-generated documentation (Swagger UI)
- http://localhost:8000/redoc : auto-generated documentation (Redoc)
- Python
- PostgreSQL : Database
- uvicorn : WebServer
- fastapi : API Framework
- SQLAlchemy : ORM
- psycopg2 : PostgreSQL adapter
- PyJWT / passlib : Password hashing & token generation
conda create --name toktik
conda activate toktik
conda install python=3.10 pip
pip install uvicorn fastapi==0.100.0 SQLAlchemy pyjwt passlib psycopg2 hashlib
conda activate toktik
uvicorn api.src.main:app --reload
- User
GET
/user/:id
(get 1 User)
name type data type description id required int user_id
http code content-type response 200
application/json
User 404
application/json
User does not exist
POST
/user/register
(get an auth token)
name type data type description username required str Username required str Valid email adress password required str Password
http code content-type response 200
application/json
""[token]
DELETE
/user/delete/:id
(Delete a User)
http code content-type response 200
application/json
User
404
application/json
User does not exist
GET
/user/token
(get 1 User, by their token)
name type data type description token required str User token
http code content-type response 200
application/json
User 404
application/json
User does not exist
POST
/user/login
(login)
name type data type description required str password required str Password
http code content-type response 200
application/json
User
PATCH
/user/:id
(Partially update an existing User)
name type data type description username optional str Username optional str password optional str Password token optional str Token
http code content-type response 200
application/json
User
404
application/json
User does not exist
- Post
GET
/post/:id
(get 1 Post)
name type data type description id required int post_id
http code content-type response 200
application/json
Post 404
application/json
Post does not exist
GET
/post/random
(get a random Post)
http code content-type response 200
application/json
Post
POST
/post/create
(create a new Post)
name type data type description title required str Title of Post description optional str Description of Post video_url required str URL of embedded video user_id required int ID of author
http code content-type response 200
application/json
Post
DELETE
/post/delete/:id
(Delete a Post)
http code content-type response 200
application/json
Post
404
application/json
Post does not exist
PATCH
/post/update/:id
(Partially update an existing Post)
name type data type description title optional str Title of Post description optional str Description of Post
http code content-type response 200
application/json
Post
404
application/json
Post does not exist
- Comment
GET
/comment/:id
(get 1 Comment)
name type data type description id required int comment_id
http code content-type response 200
application/json
Comment 404
application/json
Comment does not exist
GET
/comment/list
(get all Comments)
http code content-type response 200
application/json
Comment
COMMENT
/comment/create
(create a new Comment)
name type data type description content required str Actual comment author_id required str Author of comment post_id required str Post the comment was made on
http code content-type response 200
application/json
Comment
DELETE
/comment/delete/:id
(Delete a Comment)
http code content-type response 200
application/json
Comment
404
application/json
Comment does not exist
PATCH
/comment/update/:id
(Partially update an existing Comment)
name type data type description content optional str Actual comment
http code content-type response 200
application/json
Comment
404
application/json
Comment does not exist
Just open index.html
and you're good to go