first commit!
Build Images and Deploy / Update-PROD-Stack (push) Failing after 15s

This commit is contained in:
2026-03-18 15:44:49 -04:00
commit 3b479f8382
56 changed files with 7387 additions and 0 deletions
+111
View File
@@ -0,0 +1,111 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
username String @unique
passwordHash String
balance Float @default(2000)
researchPoints Int @default(1)
isAdmin Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
positions Position[]
trades Trade[]
passwordResets PasswordReset[]
}
model PasswordReset {
id String @id @default(cuid())
token String @unique @default(uuid())
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
expiresAt DateTime
used Boolean @default(false)
createdAt DateTime @default(now())
@@index([token])
}
model Hashtag {
id String @id @default(cuid())
tag String @unique // lowercase, no #
displayTag String // original case as entered
currentPrice Float @default(0.25)
isActive Boolean @default(true)
// Consecutive zero-result count; after 3 failed updates the hashtag auto-deactivates
zeroCount Int @default(0)
lastUpdated DateTime @default(now())
createdAt DateTime @default(now())
priceHistory PriceHistory[]
positions Position[]
trades Trade[]
@@index([isActive, lastUpdated])
}
model PriceHistory {
id String @id @default(cuid())
hashtagId String
hashtag Hashtag @relation(fields: [hashtagId], references: [id], onDelete: Cascade)
price Float
postsPerHour Float
recordedAt DateTime @default(now())
@@index([hashtagId, recordedAt])
}
model Position {
id String @id @default(cuid())
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
hashtagId String
hashtag Hashtag @relation(fields: [hashtagId], references: [id])
shares Float @default(0)
positionType PositionType
avgBuyPrice Float
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([userId, hashtagId, positionType])
@@index([userId])
@@index([hashtagId])
}
model Trade {
id String @id @default(cuid())
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
hashtagId String
hashtag Hashtag @relation(fields: [hashtagId], references: [id])
type TradeType
shares Float
price Float // price per share at time of trade
total Float // cost/proceeds of the trade
profit Float @default(0) // realized P&L (for SELL trades)
createdAt DateTime @default(now())
@@index([userId])
@@index([hashtagId])
@@index([createdAt])
}
enum PositionType {
LONG
SHORT
}
enum TradeType {
BUY_LONG
SELL_LONG
BUY_SHORT
SELL_SHORT
}
+45
View File
@@ -0,0 +1,45 @@
/**
* Seed script: creates an initial admin user.
* Usage: npm run db:seed
*
* Set ADMIN_USERNAME and ADMIN_PASSWORD env vars, or use the defaults below.
* Change the defaults before running in production.
*/
import { PrismaClient } from '@prisma/client'
import bcrypt from 'bcryptjs'
const prisma = new PrismaClient()
async function main() {
const username = process.env.ADMIN_USERNAME ?? 'admin'
const password = process.env.ADMIN_PASSWORD ?? 'changeme123'
const existing = await prisma.user.findUnique({ where: { username } })
if (existing) {
console.log(`User "${username}" already exists — skipping seed.`)
return
}
const passwordHash = await bcrypt.hash(password, 12)
const user = await prisma.user.create({
data: {
username,
passwordHash,
isAdmin: true,
balance: 10000, // admins start with extra for testing
researchPoints: 10,
},
})
console.log(`Created admin user: ${user.username} (id: ${user.id})`)
console.log('Remember to change the password after first login!')
}
main()
.catch((e) => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})