Skip to content
Draft
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
40 changes: 40 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
*.test.ts
**/node_modules

# Environment files
.env
.env.local
.env.*.local
dev.env

# IDE
.vscode
.idea
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Git
.git
.gitignore

# Logs
*.log
logs

# Test coverage
coverage

# Docker Compose (not needed in images)
docker-compose.yml
docker-compose.*.yml

# Documentation
docs
*.md
!README.md

# Misc
.turbo
.cache
12 changes: 10 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ API_GATEWAY_HOST= # e.g. http://localhost:8000
DEBUG_MODE= # true | false

# ────── PostgreSQL ──────
POSTGRES_HOST= # e.g. localhost
POSTGRES_PORT= # e.g. 5432
POSTGRES_HOST= # e.g. localhost (for local dev)
POSTGRES_PORT= # e.g. 6001 (host port, maps to 5432 in container)
POSTGRES_USER= # e.g. mark-pg-user
POSTGRES_PASSWORD= # ← secret!
POSTGRES_DB= # e.g. mark-pg
DATABASE_URL= # e.g. postgresql://mark-pg-user:password@localhost:6001/mark-pg

###############################################################################
# Add other variables (JWT_SECRET, REDIS_URL, etc.) below this line as needed
###############################################################################

# ────── Redis Cache ──────
REDIS_URL= # e.g. redis://localhost:6379 (full connection URL)
# OR use individual settings:
REDIS_HOST= # e.g. localhost
REDIS_PORT= # e.g. 6379
REDIS_PASSWORD= # Optional: Redis password if authentication is enabled
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"start:debug": "yarn start --debug --watch",
"start:dev": "yarn start --watch",
"start:prod": "node dist/main",
"test": "jest --detectOpenHandles --forceExit",
"test": "jest --detectOpenHandles --forceExit --silent --reporters=default",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- AlterTable
ALTER TABLE "AIUsage" ADD COLUMN "inputCost" DOUBLE PRECISION,
ADD COLUMN "inputTokenPrice" DOUBLE PRECISION,
ADD COLUMN "outputCost" DOUBLE PRECISION,
ADD COLUMN "outputTokenPrice" DOUBLE PRECISION,
ADD COLUMN "pricingDate" TIMESTAMP(3),
ADD COLUMN "totalCost" DOUBLE PRECISION;

-- CreateIndex
CREATE INDEX "AIUsage_assignmentId_createdAt_usageType_modelKey_idx" ON "AIUsage"("assignmentId", "createdAt", "usageType", "modelKey");

-- CreateIndex
CREATE INDEX "AssignmentAttempt_assignmentId_submitted_createdAt_idx" ON "AssignmentAttempt"("assignmentId", "submitted", "createdAt");

-- CreateIndex
CREATE INDEX "QuestionResponse_questionId_assignmentAttemptId_idx" ON "QuestionResponse"("questionId", "assignmentAttemptId");
12 changes: 11 additions & 1 deletion apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ model AIUsage {
userId String? /// The ID of the user who used the AI feature
user UserCredential? @relation(fields: [userId], references: [userId]) /// Relation to the UserCredential model
modelKey String? /// The key of the LLM model actually used for this AI operation
inputCost Float? /// Persisted input cost at write time
outputCost Float? /// Persisted output cost at write time
totalCost Float? /// Persisted total cost at write time
inputTokenPrice Float? /// Price per token (input) used for calculation
outputTokenPrice Float? /// Price per token (output) used for calculation
pricingDate DateTime? /// Date of pricing used for calculation
@@unique([assignmentId, usageType]) /// Ensure each assignment has a unique usage record for each AI feature
@@index([assignmentId, createdAt, usageType, modelKey]) /// Composite index for analytics queries
}

/// Enum to track different types of AI usage
Expand Down Expand Up @@ -402,13 +409,14 @@ model AssignmentAttempt {
preferredLanguage String?

GradingJob GradingJob[]

@@index([assignmentId])
@@index([userId])
@@index([assignmentId, submitted])
@@index([createdAt])
@@index([assignmentId, userId])
@@index([assignmentVersionId])
@@index([assignmentId, submitted, createdAt]) /// Composite index for analytics queries
}

model AssignmentAttemptQuestionVariant {
Expand Down Expand Up @@ -455,6 +463,8 @@ model QuestionResponse {
feedback Json /// Feedback on the student's response, stored as JSON
metadata Json? /// Optional additional metadata about the response
gradedAt DateTime? /// Timestamp for when the response was graded

@@index([questionId, assignmentAttemptId]) /// Composite index for analytics queries
}

/// This model captures feedback and regrading requests for assignments
Expand Down
Loading
Loading