API for the Tech With Tim website using FastAPI.
- 🏁 Getting Started
- 🐳 Running with Docker
- ✅ Linting
- 🚨 Tests
- 📚 Docs
- 📜 Licence
- ⛏️ Built Using
- ✍️ Authors
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See Running with Docker if you want to setup the API faster with Docker.
Create a new Discord application here by clicking the New application button and name it whatever you want.
Now that you have an application, go to the OAuth2 tab.
And add http://127.0.0.1:5000/auth/discord/callback to the redirects.
Install Pipenv:
pip install pipenvInstall the required packages and the packages for development with Pipenv:
pipenv install --devStart by writing this in a file named .env:
REDIS_URI=
SECRET_KEY=
POSTGRES_URI=
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=And fill in the variables with the values below:
REDIS_URIis the Redis server URI.SECRET_KEYis the key used for JWT token encoding.POSTGRES_URIis the PostgreSQL database URI.DISCORD_CLIENT_IDis the Discord application ID. Copy it from your Discord application page (see below).DISCORD_CLIENT_SECRETis the Discord application secret. Copy it from your Discord application page (see below).
For testing you need to add these environment variables:
TEST_REDIS_URIis the Connection URI for Redis testing server.TEST_POSTGRES_URIis the PostgreSQL database URI for tests.
If you are self hosting the Piston API, you need to set the PISTON_URL environment variable.
Run the API and initialise the database:
If you have not initialized submodules use this command:
git submodule update --initTo update submodules:
git submodule foreach git pull
pipenv run python launch.py runserver --initdbThe API should run at http://127.0.0.1:5000. For more information about the CLI, check the docs here.
Both the API and the frontend can be started using Docker. Using Docker is generally recommended (but not strictly required) because it abstracts away some additional set up work.
-
Setup the discord app like done here.
-
Make a file named
.envlike done here. You don't need the DB_URI environment variable though. -
Then make sure you have
dockeranddocker-composeinstalled, if not read this for docker and this for docker compose. -
Deploy the API:
docker-compose up --build api
We use a pre-commit hook for linting the code before each commit. Set up the pre-commit hook:
pipenv run pre-commit installIf you want to run the pre-commit checks before trying to commit, you can do it with:
pipenv run lintTo test the API, we use the pytest framework to make sure that the code we write works.
Run the tests:
pipenv run testWhen you contribute, you need to add tests on the features you add.
- Python - Language
- FastAPI - Backend framework
- PostDB - Database module
- pytest - Testing framework
- pytest-asyncio - Testing plugin for pytest
- @SylteA - Most of the backend
- @Shubhaankar-sharma - Docker deployment
- @takos22 - Some endpoints and markdown files
See also the list of contributors who participated in this project.





