The Codemaze API is a back-end server built using Python, Flask and Flask-RESTX that allows for auth operations on users (register, login, logout), and a multitude of user, problem and session operations. It also utilises Flask-SocketIO to generate and manage game session rooms.
Note
Live demo here
- Technologies Used
- Screenshots
- Setup
- Configuration
- Usage
- Process
- Wins and Challenges
- Bugs
- Future Features
- Python
- Pytest
- Flask
- Flask-SocketIO
- Flask-RESTX
- OpenAI API
- SQLAlchemy
Clone the repository and cd into the root repository directory:
git clone git@github.com:nine96as/reddy41_server.git && cd reddy41_serverStart up the virtual environment using pipenv:
pipenv shellInstall required dependencies:
pipenv installImportant
Please ensure you are using the Python version listed in the Technologies Used section.
-
Fetch the
PROD_DB_URIby creating a database instance, using this guide, where ElephantSQL is used as the database provider -
Fetch the
JWT_SECRET_KEYby generating your own secret key using this link -
Fetch the
OPENAI_API_KEYusing this guide
Warning
It is imperative that you do not ever share OpenAI API key with anybody, purposely or accidentally. If you accidentally commit your token, revoke it immediately and generate a new one.
- Create a
.envfile within the root repository directory, and fill it in as shown below:
FLASK_RUN_PORT=4000
PROD_DB_URI=postgresql://...
JWT_SECRET_KEY=
OPENAI_API_KEY=Run the back-end API with:
flask run- Started by creating the projects file structure.
- Began by writing our init.py and run.py.
- Next added our models, extensions, and created seperate files for our different routers.
- Created templates to be used during development
- Wrote out starter functions, routes for our users, sockets, sessions, and problems.
- Built off of the preperation, writing more complex socket functions and routes.
- Removed templates, linking up to React front end.
- Ironed out functions, routes and socket connections.
- Implemented Pytest coverage.
- Worked with and learned Flask, Flask_socketio, Flask_restx.
- Learned how to correctly use socket functions to communicate between front-end, back-end and users.
- Had to rewrite function logic to handle change from templates to front-end <-> back-end communication.
- Connecting two users and saving user info inside the same room.
- Creating routes to handle the different needs of the application.
- Refresh during 1v1 game causes connection issues, unable to reconnect to same room.
- Data sent at the end of the game is only correct for the winner, not loser.
- Info is sent multiple times, should only be sent once per call.
- Improve data stored in rooms to allow for rounds to be played with multiple questions.
- Add socket events and different types of rooms for sending messages to one another.
- Add routes to get selected users profile data to display for other users who want to view another users profile.
- Larger room sizes.
