fastapi-sveltekit-template Svelte Themes

Fastapi Sveltekit Template

This project is a template for a web application consisting of a FastAPI backend and a SvelteKit frontend. It provides a user authentication system with email and password login, as well as token-based authentication. The frontend is styled using TailwindCSS and includes login and registration pages.

Application Template

This project is a template for a web application consisting of a FastAPI backend and a SvelteKit frontend. It provides a user authentication system with email and password login, as well as token-based authentication. The frontend is styled using TailwindCSS and includes login and registration pages.

Table of Contents

Features

  • Backend:

    • User authentication with email and password.
    • Token-based authentication using JWT (JSON Web Tokens).
    • Database ORM with PeeWee
    • CORS middleware setup to accept data from the Sveltekit Application.
  • Frontend:

    • Login and registration pages.
    • Responsive design using TailwindCSS.
  • Database:

    • SQLite Database which will be saved in /shared.

Technologies

  • Backend: FastAPI - A modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
  • Frontend: SvelteKit - A framework for building web applications using Svelte, with features for routing, server-side rendering, and more.
  • Styling: TailwindCSS - A utility-first CSS framework for rapid UI development.

Installation

Follow the steps below to download the template and set up the project for local development.

Download the Project

  1. Clone the repository from GitHub:

    git clone https://github.com/faulander/fastapi-sveltekit-templage.git
    cd fastapi-sveltekit-template
    
  2. Ensure you have Python 3.12+ and Node.js 18+ installed on your computer.

Backend

  1. Navigate to the backend directory:

    cd backend
    
  2. Create a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows use: venv\Scripts\activate
    
  3. Install the required packages:

    pip install -r requirements.txt
    

    (I highly recommend using uv instead of pip/poetry etc.)

  4. Create a .env file in the backend directory and configure the following environment variables:

    ACCESS_TOKEN_EXPIRE_MINUTES =
    

Frontend

  1. Navigate to the frontend directory:

    cd ../frontend
    
  2. Install the dependencies:

    npm install
    

Running the Application

Start the Backend

From the backend directory, run the FastAPI application:

python main.py
  • The application will be available at http://localhost:8000.

Start the Frontend

From the frontend directory, start the SvelteKit application:

npm run dev
  • The application will be available at http://localhost:5173.

Usage

  1. Navigate to the frontend URL in your browser (http://localhost:5173).
  2. Use the login and registration pages to create accounts and log in.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests to enhance the application's functionality or improve the documentation.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Top categories

Loading Svelte Themes