Set up Expo SDK 56 project with TypeScript and Expo Router (file-based). Backend: - Full Convex schema (users, accounts, sessions, ads, categories, reviews, chats, messages, posts) deployed to self-hosted instance - Custom email/password auth with SHA-256 hashing via Convex actions - Query/mutation scaffolds for all domain tables - Convex environment variables configured on backend App structure: - Root layout with ConvexProvider, ThemeProvider, AuthContext - (auth) group: login and register screens (Macedonian UI) with role selection (handyman/customer) - (tabs) group: 5 tabs (Home, Explore, Posts, Chat, Profile) each with nested Stack layouts - Placeholder detail screens for ad, post, chat, review flows - 404 not-found screen in Macedonian UI primitives (components/ui/): - Button (4 variants), Input, Card, Loading, Avatar, Rating, Badge - ThemeProvider with light/dark palette via React context All user-facing strings in Macedonian. Code identifiers in English. TypeScript passes with zero errors.
94 lines
2.5 KiB
TypeScript
94 lines
2.5 KiB
TypeScript
import { defineSchema, defineTable } from "convex/server";
|
|
import { v } from "convex/values";
|
|
|
|
export default defineSchema({
|
|
users: defineTable({
|
|
name: v.string(),
|
|
phone: v.optional(v.string()),
|
|
email: v.optional(v.string()),
|
|
role: v.string(),
|
|
avatarId: v.optional(v.string()),
|
|
reviewCount: v.number(),
|
|
createdAt: v.number(),
|
|
}).index("by_email", ["email"]),
|
|
|
|
accounts: defineTable({
|
|
userId: v.id("users"),
|
|
provider: v.string(),
|
|
providerId: v.string(),
|
|
secret: v.string(),
|
|
createdAt: v.number(),
|
|
}).index("by_provider_email", ["provider", "providerId"]),
|
|
|
|
sessions: defineTable({
|
|
userId: v.id("users"),
|
|
token: v.string(),
|
|
expiresAt: v.number(),
|
|
createdAt: v.number(),
|
|
}).index("by_token", ["token"]),
|
|
|
|
ads: defineTable({
|
|
handymanId: v.id("users"),
|
|
title: v.string(),
|
|
description: v.string(),
|
|
category: v.string(),
|
|
location: v.string(),
|
|
lat: v.optional(v.number()),
|
|
lng: v.optional(v.number()),
|
|
priceRange: v.optional(v.string()),
|
|
imageIds: v.optional(v.array(v.string())),
|
|
availability: v.optional(v.string()),
|
|
ratingAvg: v.optional(v.number()),
|
|
reviewCount: v.number(),
|
|
createdAt: v.number(),
|
|
updatedAt: v.number(),
|
|
})
|
|
.index("by_handyman", ["handymanId"])
|
|
.index("by_category", ["category"]),
|
|
|
|
categories: defineTable({
|
|
name: v.string(),
|
|
slug: v.string(),
|
|
icon: v.optional(v.string()),
|
|
sortOrder: v.number(),
|
|
}).index("by_slug", ["slug"]),
|
|
|
|
reviews: defineTable({
|
|
adId: v.id("ads"),
|
|
customerId: v.id("users"),
|
|
handymanId: v.id("users"),
|
|
rating: v.number(),
|
|
comment: v.optional(v.string()),
|
|
createdAt: v.number(),
|
|
})
|
|
.index("by_ad", ["adId"])
|
|
.index("by_handyman", ["handymanId"]),
|
|
|
|
chats: defineTable({
|
|
participantIds: v.array(v.id("users")),
|
|
lastMessageAt: v.number(),
|
|
createdBy: v.id("users"),
|
|
}).index("by_participant", ["participantIds"]),
|
|
|
|
messages: defineTable({
|
|
chatId: v.id("chats"),
|
|
senderId: v.id("users"),
|
|
content: v.string(),
|
|
imageId: v.optional(v.string()),
|
|
createdAt: v.number(),
|
|
}).index("by_chat", ["chatId", "createdAt"]),
|
|
|
|
posts: defineTable({
|
|
customerId: v.id("users"),
|
|
title: v.string(),
|
|
description: v.string(),
|
|
category: v.optional(v.string()),
|
|
location: v.optional(v.string()),
|
|
budget: v.optional(v.string()),
|
|
status: v.string(),
|
|
createdAt: v.number(),
|
|
updatedAt: v.number(),
|
|
})
|
|
.index("by_customer", ["customerId"])
|
|
.index("by_status", ["status"]),
|
|
}); |