Skip to content

API for storing and inspecting swimming results from competitions, using graphql and supabase for storing users

License

Notifications You must be signed in to change notification settings

Pjiwm/swimtimes-api

Repository files navigation

Swimtimes

GitHub commit activity GitHub top language

Rust React Vite TypeScript

Available via

Web UI

GraphQL API

Installation

To install and run the Swimtimes application, follow these steps:

  1. Install Docker, Node, and the Rust compiler.
  2. Create a secrets.toml file for Shuttle deployment with the following content:
DATABASE_URL='mysql://root:1337@localhost:3306/swimdb'
RUST_LOG="info,sqlx=off,async_graphql=warn,api=info"
local_uri="postgres://postgres:postgres@localhost:5432/swimdb"
JWT_SECRET=
  1. Install the cargo-shuttle tool by running:
cargo install cargo-shuttle
  1. Setup a project on Shuttle-rs

  2. Setup Supabase or any other JWT/JWK provider

  3. in /swimtimes/app/app.config.ts set the config

const config = {
  apiUrl: process.env.NODE_ENV === 'development' ? 'http://localhost:8000' : 'https://<url>.shuttleapp.rs',
  authClientUrl: "https://<id>.supabase.co",
  anonKey: "<anonkey>"
};

export default config;
  1. Start the container using Docker Compose:
docker-compose up -d
  1. Run the application with:
cargo shuttle run

Application Overview

Entities

Swimmer

Field Type Description
id i32 Primary Key
name String Swimmer's name
date_of_birth Date Swimmer's date of birth
team i32 (FK) Foreign key to Team

Team

Field Type Description
id i32 Primary Key
name String Team's name
founding_date Date Team's founding date
address String Team's address
zip_code String Team's zip code

SwimTime

Field Type Description
id i32 Primary Key
competition i32 (FK) Foreign key to Competition
distance i32 Swim distance in meters
stroke String Swim stroke type
time i32 Swim time in seconds
swimmer i32 (FK) Foreign key to Swimmer

Tech Stack

  • Docker
  • Node.js
  • React
  • Vite
  • Rust
  • Axum
  • SQLx/Sea ORM
  • GraphQL (async-graphql)
  • Postgresql
  • Supabase

Directory

├── Cargo.lock
├── Cargo.toml
├── LICENSE
├── Secrets.toml
├── Shuttle.toml (use this instead of .env)
├── api (API library for Axum server)
├── app (React app)
├── docker-compose.yml
├── entities.sh (Migration command, creates entity files)
├── entity (Contains all models/entities for the project)
├── example.env
├── migration (Sea ORM migrations)
├── repository (manages commands to DB)
├── src (main crate, spins up web server from API using Shuttle-rs)
├── static (output directory for building react app. Will be served by API)
├── target
└── tests

Releases

No releases published

Packages

No packages published