https://github.com/kevinkoech357/spitfire-events-backend
A REST API built using flask for serving dynamic content for an android-based events app.
https://github.com/kevinkoech357/spitfire-events-backend
flask mysql-database sqlalchemy
Last synced: 3 months ago
JSON representation
A REST API built using flask for serving dynamic content for an android-based events app.
- Host: GitHub
- URL: https://github.com/kevinkoech357/spitfire-events-backend
- Owner: kevinkoech357
- License: mit
- Created: 2023-09-21T09:18:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-22T16:39:12.000Z (about 1 year ago)
- Last Synced: 2025-01-05T05:41:40.915Z (4 months ago)
- Topics: flask, mysql-database, sqlalchemy
- Language: Python
- Homepage:
- Size: 718 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Events App Team SpitFire
## Table Of Contents
- [Introduction](#introduction)
- [Base URI / Live Deployment](#base-uri--live-deployment)
- [Local Server Setup](#local-server-setup)
- [Clone The Repository](#clone-the-repository)
- [Install Dependencies](#install-dependencies)
- [Configure Environment Variables](#configure-environment-variables)
- [Run the Server](#run-the-server)
- [Run API Tests](#run-api-tests)
- [Authentication](#authentication)
- [Endpoints](#endpoints)
- [Authentication Endpoint](#authentication-endpoint)
- [Sample Usage](#sample-usage)
- [Error Handling](#error-handling)
- [UML Class Diagram](#uml-class-diagram)
- [Limitations and Assumptions](#limitations-and-assumptions)
- [Authors](#authors)## Introduction
Welcome to the Events App documentation for Team SpitFire! This document
provides detailed information on setting up the server locally, API endpoints,
authentication, sample usage, error handling, and more.---
## Base URI / Live Deployment
The Events App is hosted for live testing at [insert_base_uri_here]. Replace
`[insert_base_uri_here]` with the actual base URI where the API is deployed.---
## Local Server Setup
### Clone The Repository
To get started with the local development environment, clone the repository:
```bash
$ git clone https://github.com/kevinkoech357/spitfire-events-backend.git
$ cd spitfire-events-backend
```### Install Dependencies
You can set up the environment using either `venv` or `pipenv`. Here are
instructions for both:Using `venv`:
```bash
# create Virtual Environment
$ python3 -m venv venv# Activate Virtual Env
$ source venv/bin/activate# Install Dependencies
$ pip install -r requirements.txt
```Using `pipenv`:
```bash
$ pip install pipenv# create virtuel environment
$ pipenv --python 3.10# Activate virtual env
$ pipenv shell# install dependencies in requirements.txt or pipfile
$ pipenv install
```### Configure Environment Variables
Make sure to set the following environment variables:
SECRET_KEY: [Your Secret Key]
SQLALCHEMY_DATABASE_URI: [Your Database URI]
OAUTHLIB_INSECURE_TRANSPORT: 1
ANDROID_CLIENT_ID:
IOS_CLIENT_ID:### Run the Server
```bash
$ python3 run.py
```### Run API Tests
**Note:** ensure you are connected to the internet before running tests and are
in `spitfire-events` directory```bash
# install test suite and HTTP requests library
$ pip install requests pytest# Run the tests in test_crud.py
$ pytest test_event.py -v
```[click for test_event.py file](test_event.py)
---
## **Authentication**
The authentication mechanism used by this API is Google oAuth2 with session
cookies see [Authentication here](./API_DOCUMENTATION.md)## **EndPoints**
see [Api Documentation here](./API_DOCUMENTATION.md)
### Authentication Endpoint
`POST 'API/auth'`
- Retrieves a person from the database using user id
- **Request Body**:
- **Input**: JSON with auth token.
```
{
"token": "google id token",
}
```
- Returns: JSON response with a message and person object containing `id`,
`name` and `date created`Example Response
```json
{
"message": "success",
"name": "user display name",
"email": "user email",
"avatar": "user image url"
}
```## _status code: 200_ see [Api Documentation here](./API_DOCUMENTATION.md)
## Sample Usage
## **Error Handling**
> Errors are returned as JSON objects in the following format with their error
> code```json
{
"error": "error name",
"message": "error description"
}
```
The API will return 5 error types, with diffreent descriptions when requests
fail;- 400: Request unprocessable
- 403: Forbidden
- 404: resource not found
- 422: Bad Request
- 429: Too Many Requests(rate limiting)
- 500: Internal server error