The back-end repository provides the API to fetch words for the specific game level, with data stored in a database.
- RESTful API to retrieve a list of words for a specific level.
- API endpoints to interact with the front end and provide necessary data for the game.
- Database for storing and retrieving words and level information.
- Flask: Python web framework for building the API.
- PostgreSQL: Database for storing words and level information.
- SQLAlchemy: ORM for interacting with the database.
- Stores user-related information (id, username, password_hash, avatar).
- Primary Key: id.
- Has a one-to-many relationship with user_achievements and games.
- Tracks achievements for each user.
- Fields: achievement_id (Primary Key), user_id (Foreign Key to users.id), description.
- Linked to the users table via user_id.
- Represents game instances played by users.
- Fields: id (Primary Key), user_id (Foreign Key to users.id), score.
- Linked to the users table via user_id.
- Stores words for the game.
- Fields: id (Primary Key), word, grade, description.
- Serves as a word bank for the game.
- Many-to-many relationship between games and words.
- Fields: game_id (Foreign Key to games.id), word_id (Foreign Key to words.id).
When a user starts a new round of the game:
- A new record is created in the games table (let's call this the round ID).
- The user's selected level is used to filter words from the words table (e.g., by grade or another level-related attribute).
- Five words are randomly selected from this filtered set.
For each of the five words selected, a new record is added to the games_words table to associate the selected words with the newly created game/round ID.
The API returns:
- The round ID from the games table.
- The five selected words (their word values).
- Their definitions (the description field from the words table).
-
Clone the repository:
git clone https://github.com/hintow/SightStack-back-end cd SightStack-back-end
-
Create a virtual environment and activate it:
python3 -m venv .venv source .venv/bin/activate
-
Install the dependencies:
pip install -r requirements.txt
-
Set up the database:
- Ensure PostgreSQL is installed and running.
- Create a database named
sightstack_dev
. - Update the
SQLALCHEMY_DATABASE_URI
in the .env file with your database credentials.
-
Run the migrations:
flask db upgrade
-
Start the Flask application:
flask run --debug
- Run the tests:
pytest
- GET /words/level/: Retrieve a list of words for a specific level.
- POST /register: Register a new user.
- POST /login: Login a user.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.