Skip to content

A referral system built using FastAPI. This system allows users to generate referral codes, check status of referral codes and invalidate codes after a set stale period.

Notifications You must be signed in to change notification settings

buabaj/python-referral-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-referral-system

A referral system built using FastAPI and SQLite3. This system allows users to generate referral codes, check status of referral codes, redeem referral codes and invalidate codes after a set stale period.

Features

  • Built-in Referral Code Expiry
  • Generate referral code
  • Check validity of referral Code
  • Redeem referral code
  • Strong types and type enforcing

Core Requirements

  • FastAPI
  • SQLite3

Project Setup

  1. Make sure you have SQLite3 installed on your machine. Next, Clone this repo and navigate to the root directory.
git clone https://github.com/buabaj/python-referral-system.git
cd python-referral-system
  1. Create and activate a virtual environment for the requirements of your project.
python3 -m venv .venv/
source .venv/bin/activate
pip install -r requirements.txt
  1. Start your sqlite3 server in your terminal using the command:
sqlite3 test.db
  1. Paste the following SQL command in the sqlite3 prompt that comes on in your terminal to create your database tables:
CREATE TABLE Users(
    user_id INTEGER PRIMARY KEY AutoIncrement,
    first_name TEXT NOT NULL,
    last_name TEXT NOT NULL,
    phone TEXT,
    email TEXT NOT NULL,
    token TEXT,
    created_at DATE,
    updated_at DATE
);

CREATE TABLE Referrals(
    referral_code_id INTEGER PRIMARY KEY AutoIncrement,
    referral_code TEXT NOT NULL,
    created_at DATE,
    is_active boolean NOT NULL,
    user_id INT NOT NULL,
    foreign key(user_id) references Users(user_id)

);
  1. Run the following code in a different terminal to run your local FastAPI server:
python3 app.py
  1. Head to localhost:8000/docs in your browser to test the Implementation of the referral system endpoints and documentation in an interactive SWAGGER UI API Documentation playground.

About

A referral system built using FastAPI. This system allows users to generate referral codes, check status of referral codes and invalidate codes after a set stale period.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages