Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Vite + FastAPI + Supabase Full-Stack Template

  • React frontend powered by Vite & Mantine component library
  • FastAPI backend with Docker support
  • Supabase Postgres database & optional authentication

Getting Started

1. Clone the repository

git clone https://github.com/<your-github-org>/vite-fastapi-template.git
cd vite-fastapi-template

2. Backend Setup

  1. Install dependencies

    cd server
    pip install -r requirements.txt
  2. Configure .env:

    cp .env.example .env
    • PROJECT_NAME: container name
    • PORT: port for the server
    • SUPABASE_URL and SUPABASE_KEY: Supabase project credentials
    • DATABASE_URL and DATABASE_KEY: Credentials for Postgres database
  3. Initialize the database, creating a super user, initializing tables, and data:

    make init_db
  4. Build and run the Docker container:

    make build
    make run
    
    # QoL
    make make      # Runs build + run
    make rebuild   # Runs stop + build + run if a container is already running
  5. Stop or clean up:

    make stop     # stops the running container
    make clean    # removes the image

Database Migrations

  1. Install Alembic (if not already installed):
    pip install alembic
  2. Create a new migration script:
    alembic revision --autogenerate -m "Initial migration"
  3. Apply migrations:
    alembic upgrade head
    Read more about how to use Alembic here.

3. Frontend Setup

  1. Install dependencies

    cd frontend
    npm install
  2. Copy and configure .env

    cp .env.example .env
    • VITE_API_URL: backend URL (e.g. http://localhost:8181)
    • VITE_SUPABASE_URL and VITE_SUPABASE_KEY: your Supabase credentials
  3. Start the dev server:

    npm run dev

Makefile Info

Optional command lines that might make dev experience a bit smoother.

Usage:

make <target>                             # At the respective root
make -C /full/path/to/project <target>    # From anywhere else

Frontend Makefile

Target Description
run Launch Vite dev server (npm run dev)

Backend Makefile

Target Description
build Build the Docker image (docker build -t $(IMAGE_NAME) .)
run Run the container (docker run --rm --name $(CONTAINER_NAME) -p $(PORT):$(PORT) $(IMAGE_NAME))
stop Stop the running container (docker stop $(CONTAINER_NAME))
clean Stop container and remove image (make stop && docker rmi $(IMAGE_NAME))
make Alias for build + run
rebuild Stop, build, and run again
init_db Initialize database and seed initial data (python -m app.db.init_db)

Backend builds upon AtticusZeller's FastAPI template.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages