Skip to content

coolworld2049/fastapi_ecommerce

Repository files navigation

Deploy

fastapi-logo postgres-logo mongodb-logo prisma-logo

auth-service.png

auth-service-user-table.png

store_service.png

generator client {
  provider               = "prisma-client-py"
  partial_type_generator = "./prisma/partial_types.py"
  interface              = asyncio
  recursive_type_depth   = 8
}

datasource db {
  provider = "mongodb"
  url      = env("MONGODB_URL")
}

enum OrderStatus {
  pending
  awaiting_payment
  awaiting_fulfilment
  completed
  canceled
  declined
  refunded
  disputed
  partially_refunded
  deleted
}

model Category {
  id          String    @id @default(auto()) @map("_id") @db.ObjectId
  name        String    @unique
  description String?   
  created_at  DateTime? @default(now())
  updated_at  DateTime? @updatedAt
  products    Product[] 
}

model Product {
  id             String         @id @default(auto()) @map("_id") @db.ObjectId
  title          String         @unique
  stock          Int            
  price          Float          
  description    String?        
  created_at     DateTime?      @default(now())
  updated_at     DateTime?      @updatedAt
  category       Category       @relation(fields: [category_id], references: [id])
  category_id    String         @db.ObjectId
  order_products OrderProduct[] 
}

model Order {
  id             String         @id @default(auto()) @map("_id") @db.ObjectId
  status         OrderStatus    @default(pending)
  cost           Float?         
  created_at     DateTime?      @default(now())
  updated_at     DateTime?      @updatedAt
  user_id        String         
  order_products OrderProduct[] 
}

model OrderProduct {
  id         String   @id @default(auto()) @map("_id") @db.ObjectId
  order      Order    @relation(fields: [order_id], references: [id])
  order_id   String   @db.ObjectId
  product    Product? @relation(fields: [product_id], references: [id])
  product_id String?  @db.ObjectId
}

prisma-studio.png

dev mode

.env

STAGE=dev

add the following lines to /etc/hosts

127.0.0.1 auth-service.fastapi-ecommerce.com
127.0.0.1 store-service.fastapi-ecommerce.com