Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 15 additions & 38 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ name: Main Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test-and-build:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

Expand All @@ -22,48 +21,25 @@ jobs:
run: npm install

- name: Generate Prisma Client
env:
DATABASE_URL: sqlite://./dummy.db
run: npx prisma generate --schema=server/prisma/schema.prisma

- name: Lint
run: npm run lint

- name: Build
env:
DATABASE_URL: sqlite://./dummy.db
- name: Build Application
run: npm run build

deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: test-and-build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v5
- name: Connect to Tailscale
uses: tailscale/github-action@v3
with:
node-version: '24'
cache: 'npm'

- name: Install dependencies
run: npm install
authkey: ${{ secrets.TAILSCALE_AUTH_KEY }}

- name: Validate Secrets
run: |
if [ -z "${{ secrets.REMOTE_HOST }}" ]; then echo "Error: REMOTE_HOST secret is missing"; exit 1; fi
if [ -z "${{ secrets.REMOTE_USER }}" ]; then echo "Error: REMOTE_USER secret is missing"; exit 1; fi
if [ -z "${{ secrets.SSH_PRIVATE_KEY }}" ]; then echo "Error: SSH_PRIVATE_KEY secret is missing"; exit 1; fi

- name: Build Application
env:
DATABASE_URL: sqlite://./dummy.db
run: |
npx prisma generate --schema=server/prisma/schema.prisma
npm run build

- name: Deploy via rsync
env:
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
Expand All @@ -86,17 +62,18 @@ jobs:
--exclude 'logs/' \
--exclude '*.log' \
./ $REMOTE_USER@$REMOTE_HOST:~/SigiLife/
rm deploy_key.pem


- name: Restart Application
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
env:
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
run: |
ssh -i deploy_key.pem -o StrictHostKeyChecking=no $REMOTE_USER@$REMOTE_HOST << 'EOF'
cd ~/SigiLife
npm install
npx prisma migrate deploy --schema=server/prisma/schema.prisma
npx prisma generate --schema=server/prisma/schema.prisma
pm2 restart sigilife || pm2 start ecosystem.config.cjs --env production
EOF
rm deploy_key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE `users` ADD COLUMN `hasCompletedTutorial` BOOLEAN NOT NULL DEFAULT false;
133 changes: 77 additions & 56 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
generator client {
provider = "prisma-client-ts"
output = "./generated"
provider = "prisma-client-ts"
output = "./generated"
}

datasource db {
provider = "mysql"
}

model User {
id Int @id @default(autoincrement())
username String? @unique @db.VarChar(100)
email String @unique @db.VarChar(255)
name String? @db.VarChar(255)
picture String? @db.VarChar(500)
googleId String? @unique @db.VarChar(255)
avatar Int @default(0)
theme Int @default(1)
color_theme String @default("cyber") @db.VarChar(50)
isAdmin Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
homeLocation String? @db.VarChar(500)
hasCompletedTutorial Boolean @default(false)
sigils Sigil[]
following Follow[] @relation("follower")
followers Follow[] @relation("following")
id Int @id @default(autoincrement())
username String? @unique @db.VarChar(100)
email String @unique @db.VarChar(255)
name String? @db.VarChar(255)
picture String? @db.VarChar(500)
googleId String? @unique @db.VarChar(255)
avatar Int @default(0)
theme Int @default(1)
color_theme String @default("cyber") @db.VarChar(50)
isAdmin Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
homeLocation String? @db.VarChar(500)
hasCompletedTutorial Boolean @default(false)
sigils Sigil[]
following Follow[] @relation("follower")
followers Follow[] @relation("following")
arPlacement ArPlacement?

@@map("users")
@@map("users")
}

model Sigil {
id Int @id @default(autoincrement())
name String @db.VarChar(100)
userId Int
intention String? @db.Text
canvasData String? @db.LongText
imageData String? @db.LongText
isCharged Boolean @default(false)
locationName String? @db.VarChar(200)
latitude Decimal? @db.Decimal(10, 8)
longitude Decimal? @db.Decimal(11, 8)
createdAt DateTime @default(now())
sigilGroups SigilGroup[]
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
id Int @id @default(autoincrement())
name String @db.VarChar(100)
userId Int
intention String? @db.Text
canvasData String? @db.LongText
imageData String? @db.LongText
isCharged Boolean @default(false)
locationName String? @db.VarChar(200)
latitude Decimal? @db.Decimal(10, 8)
longitude Decimal? @db.Decimal(11, 8)
createdAt DateTime @default(now())
sigilGroups SigilGroup[]
arPlacement ArPlacement?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@map("sigils")
@@map("sigils")
}

model Follow {
Expand All @@ -53,38 +55,57 @@ model Follow {
followingId Int
createdAt DateTime @default(now())

follower User @relation("follower", fields: [followerId], references: [id], onDelete: Cascade) // ← add
following User @relation("following", fields: [followingId], references: [id], onDelete: Cascade) // ← add
follower User @relation("follower", fields: [followerId], references: [id], onDelete: Cascade)
following User @relation("following", fields: [followingId], references: [id], onDelete: Cascade)

@@unique([followerId, followingId])
@@map("follows")
}



model SigilGroup {
id Int @id @default(autoincrement())
sigilId Int
groupMember String @db.VarChar(100)
sigil Sigil @relation(fields: [sigilId], references: [id], onDelete: Cascade)
id Int @id @default(autoincrement())
sigilId Int
groupMember String @db.VarChar(100)
sigil Sigil @relation(fields: [sigilId], references: [id], onDelete: Cascade)

@@index([sigilId], map: "sigil_groups_sigilId_fkey")
@@map("sigil_groups")
@@index([sigilId])
@@map("sigil_groups")
}

model SvgVector {
id Int @id @default(autoincrement())
sigilId Int? @map("sigil_id")
filename String @db.Text
vectorData String @map("vector_data") @db.Text
width Int
height Int
fileSize Int @map("file_size")
createdAt DateTime @default(now())
@@map("svg_vectors")
id Int @id @default(autoincrement())
sigilId Int? @map("sigil_id")
filename String @db.Text
vectorData String @map("vector_data") @db.Text
width Int
height Int
fileSize Int @map("file_size")
createdAt DateTime @default(now())
@@map("svg_vectors")
}

model sessions {
session_id String @id @db.VarChar(128)
expires Int @db.UnsignedInt
data String? @db.MediumText
session_id String @id @db.VarChar(128)
expires Int @db.UnsignedInt
data String? @db.MediumText
@@map("sessions")
}

model ArPlacement {
id Int @id @default(autoincrement())
userId Int @unique
sigilId Int @unique
posX Decimal @db.Decimal(10, 5)
posY Decimal @db.Decimal(10, 5)
posZ Decimal @db.Decimal(10, 5)
rotationX Decimal @db.Decimal(10, 5)
rotationY Decimal @db.Decimal(10, 5)
rotationZ Decimal @db.Decimal(10, 5)
rotationW Decimal @db.Decimal(10, 5)
createdAt DateTime @default(now())

sigil Sigil @relation(fields: [sigilId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@map("ar_placements")
}
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useUser } from '@/context/UserContext';
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Landing Page & Log in
import ProtectedRoute from './components/LogInAuth/ProtectedRoute'
import LandingPage from './components/LogInAuth/LandingPage'
import CreateProfile from './components/LogInAuth/CreateProfile'


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ User
Expand Down Expand Up @@ -67,6 +68,7 @@ console.log('App render - isLoading:', isLoading, 'path:', window.location.pathn
{/* Auth flow */}
<Route path="/login" element={<LandingPage />} />
<Route path="/" element={<LandingPage />} />
<Route path="/create-profile" element={<ProtectedRoute><CreateProfile /></ProtectedRoute>} />

{/* User */}
<Route path="/settings" element={<ProtectedRoute><UserSettings /></ProtectedRoute>} />
Expand Down
92 changes: 92 additions & 0 deletions src/components/LogInAuth/CreateProfile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import * as SwitchPrimitive from "@radix-ui/react-switch";
import { useUser } from '@/context/UserContext';
import MapSearchBox from '@/components/SigilRoomHome/Grimoire/LeftPage/Map/MapSearchBox';

export default function CreateProfile() {
const { user, setUser } = useUser();
const navigate = useNavigate();
const [username, setUsername] = useState('');
const [avatar, setAvatar] = useState('0');
const [homeLocation, setHomeLocation] = useState('');
const [isDark, setIsDark] = useState(false);

const handleCreate = async () => {
if (!user) return;
try {
const res = await fetch(`/api/users/${user.id}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
username,
avatar: parseInt(avatar),
theme: isDark ? 1 : 0,
homeLocation
})
});
const updated = await res.json();
setUser(updated);
navigate('/make-sigil/write');
} catch (err) {
console.error(err);
}
};

const handleThemeChange = (checked: boolean) => {
setIsDark(checked);
document.documentElement.classList.toggle("dark", checked);
};

return (
<div className='maincontainer'>
<div className="landingpage">
<div className="makeprofile">
<h1>Create Your Profile:</h1>
<label>Choose a SigiLife Username!
<br />
<input className="textinput" type="text" value={username} onChange={(e) => setUsername(e.target.value)} />
</label>

<label className='avatarchoicebox'>Choose a SigiLord:
<div className='avatarchoice'>
<img className='avatar' src='Avatar1.png' alt='trench-coat-detective' onClick={() => setAvatar('0')}
style={{ outline: avatar === '0' ? '2px solid #2b0681' : 'none', cursor: 'pointer', height: 100, borderRadius: "20px" }} />
<img className='avatar' src='Avatar2.png' alt='dress-detective' onClick={() => setAvatar('1')}
style={{ outline: avatar === '1' ? '2px solid #2b0681' : 'none', cursor: 'pointer', height: 100, borderRadius: "20px" }} />
</div>
</label>

<label>Choose your Home Sigil Location:
<MapSearchBox
accessToken={import.meta.env.VITE_MAPBOX_TOKEN || ''}
onRetrieve={(res) => {
if (res.features && res.features.length > 0) {
setHomeLocation(res.features[0].properties.full_address || res.features[0].properties.name);
}
}}
/>
</label>

<label>
Dark or Light Theme:<br />
<SwitchPrimitive.Root checked={isDark} onCheckedChange={handleThemeChange}
className="relative inline-flex h-6 w-11 items-center rounded-full bg-purple-300 data-[state=checked]:bg-purple-500">
<SwitchPrimitive.Thumb className="block h-4 w-4 translate-x-1 rounded-full bg-white transition-transform data-[state=checked]:translate-x-6" />
</SwitchPrimitive.Root>
{isDark ? "Dark" : "Light"}
</label>

<button
className="createaccountbutton"
style={{ borderRadius: "20px", backgroundColor: "white", borderColor: "#e0e0e0", borderWidth: "1px", width: "135px", height: "40px", alignSelf: "center", marginTop: "20px", color: "black", opacity: (!username || !homeLocation) ? 0.5 : 1 }}
disabled={!username || !homeLocation}
onClick={handleCreate}
>
Save Profile
</button>
</div>
</div>
</div>
);
}
Loading