Skip to content
Yanis Moyon edited this page Oct 8, 2024 · 5 revisions

The Server part of the project is made using SvelteKit, a JavaScript framework made to simplify all server actions (fetch, http protocol, ...) and related to Svelte framework.

Database

The project data is stored only in a AWS cluster using Vercel, a deployer and web-app maintainer. The database is written in SQL using PostgreSQL framework.

The following is a representation of our database schemas :

enum UserRole {
  USER
  API_USER
  ADMIN
}

enum Provider {
  DISCORD
  STEAM
  SPOTIFY
}

model User {
  id             Int       @id @unique @default(autoincrement())
  username       String    @default("")
  email          String    @unique
  role           UserRole  @default(USER)
  token          String    @unique
  hashedPassword String
  createdAt      DateTime  @default(now())
  services       Service[]
}

model Service {
  id           Int      @id @unique @default(autoincrement())
  providerType Provider
  metadata     Json?
  user         User?    @relation(fields: [userId], references: [id])
  userId       Int?
}

model Program {
  id      Int      @id @unique @default(autoincrement())
  name    String
  actions Action[]
}

model Action {
  id        Int        @id @unique @default(autoincrement())
  programId Int?
  metadata  Json?
  program   Program?   @relation(fields: [programId], references: [id])
  reactions Reaction[]
}

model Reaction {
  id       Int     @id @unique @default(autoincrement())
  actionId Int?
  metadata Json?
  action   Action? @relation(fields: [actionId], references: [id])
}

API Routes

The API routes are located in /api route.

About JSON (/api/about.json)

This route is made to list all current implemented services, their actions and related reactions. As of this moment, the route is currently templated and not working dynamically with our database.

Authentication (/api/auth)

This route is made to encapsulate all the authentication methods for the API user. Currently, the following methods are available :

  • /api/auth/login: Used to login the user using JWT encryption.
  • /api/auth/register: Used to register the user using JWT encryption.
  • /api/auth/spotify: Used to redirect the user to Spotify Authentication page

Service Linking (/api/link)

This route is made to encapsulate service routes to link the latter to the user. The routes architecture are the following : /api/link/{service_name} Currently, Spotify is the only service linkable.

Service Unlinking (/api/unlink)

This route is the same as Service Linking

Clone this wiki locally