Initial commit - PromptTech
This commit is contained in:
5
archive/techzone-source/backend/.env
Normal file
5
archive/techzone-source/backend/.env
Normal file
@@ -0,0 +1,5 @@
|
||||
MONGO_URL="mongodb://localhost:27017"
|
||||
DB_NAME="test_database"
|
||||
CORS_ORIGINS="*"
|
||||
JWT_SECRET="techzone-super-secret-key-2024-production"
|
||||
DATABASE_URL="postgresql+asyncpg://techzone_user:techzone_pass@localhost:5432/techzone"
|
||||
27
archive/techzone-source/backend/database.py
Normal file
27
archive/techzone-source/backend/database.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy import create_engine
|
||||
import os
|
||||
|
||||
# PostgreSQL connection string
|
||||
DATABASE_URL = os.environ.get('DATABASE_URL', 'postgresql+asyncpg://techzone_user:techzone_pass@localhost:5432/techzone')
|
||||
SYNC_DATABASE_URL = DATABASE_URL.replace('+asyncpg', '')
|
||||
|
||||
# Async engine for FastAPI
|
||||
async_engine = create_async_engine(DATABASE_URL, echo=False)
|
||||
AsyncSessionLocal = async_sessionmaker(async_engine, class_=AsyncSession, expire_on_commit=False)
|
||||
|
||||
# Sync engine for migrations and seeding
|
||||
sync_engine = create_engine(SYNC_DATABASE_URL, echo=False)
|
||||
|
||||
async def get_db():
|
||||
async with AsyncSessionLocal() as session:
|
||||
try:
|
||||
yield session
|
||||
finally:
|
||||
await session.close()
|
||||
|
||||
async def init_db():
|
||||
from models import Base
|
||||
async with async_engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
232
archive/techzone-source/backend/models.py
Normal file
232
archive/techzone-source/backend/models.py
Normal file
@@ -0,0 +1,232 @@
|
||||
from sqlalchemy import Column, Integer, String, Float, Boolean, DateTime, Text, ForeignKey, Enum as SQLEnum, JSON
|
||||
from sqlalchemy.orm import relationship, declarative_base
|
||||
from sqlalchemy.sql import func
|
||||
from datetime import datetime, timezone
|
||||
import enum
|
||||
import uuid
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
def generate_uuid():
|
||||
return str(uuid.uuid4())
|
||||
|
||||
class OrderStatus(enum.Enum):
|
||||
PENDING = "pending"
|
||||
PROCESSING = "processing"
|
||||
LAYAWAY = "layaway"
|
||||
SHIPPED = "shipped"
|
||||
DELIVERED = "delivered"
|
||||
CANCELLED = "cancelled"
|
||||
REFUNDED = "refunded"
|
||||
ON_HOLD = "on_hold"
|
||||
|
||||
class UserRole(enum.Enum):
|
||||
USER = "user"
|
||||
ADMIN = "admin"
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
email = Column(String(255), unique=True, nullable=False, index=True)
|
||||
name = Column(String(255), nullable=False)
|
||||
password = Column(String(255), nullable=False)
|
||||
role = Column(SQLEnum(UserRole), default=UserRole.USER)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
cart_items = relationship("CartItem", back_populates="user", cascade="all, delete-orphan")
|
||||
orders = relationship("Order", back_populates="user")
|
||||
reviews = relationship("Review", back_populates="user")
|
||||
bookings = relationship("Booking", back_populates="user")
|
||||
|
||||
class Category(Base):
|
||||
__tablename__ = "categories"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
name = Column(String(100), unique=True, nullable=False)
|
||||
slug = Column(String(100), unique=True, nullable=False)
|
||||
description = Column(Text)
|
||||
type = Column(String(50), default="product") # product or service
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
products = relationship("Product", back_populates="category_rel")
|
||||
services = relationship("Service", back_populates="category_rel")
|
||||
|
||||
class Product(Base):
|
||||
__tablename__ = "products"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
name = Column(String(255), nullable=False)
|
||||
description = Column(Text)
|
||||
price = Column(Float, nullable=False)
|
||||
category = Column(String(100), nullable=False)
|
||||
category_id = Column(String(36), ForeignKey("categories.id"), nullable=True)
|
||||
image_url = Column(String(500))
|
||||
stock = Column(Integer, default=10)
|
||||
low_stock_threshold = Column(Integer, default=5)
|
||||
brand = Column(String(100))
|
||||
specs = Column(JSON, default={})
|
||||
is_active = Column(Boolean, default=True)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
category_rel = relationship("Category", back_populates="products")
|
||||
cart_items = relationship("CartItem", back_populates="product")
|
||||
order_items = relationship("OrderItem", back_populates="product")
|
||||
reviews = relationship("Review", back_populates="product", cascade="all, delete-orphan")
|
||||
inventory_logs = relationship("InventoryLog", back_populates="product", cascade="all, delete-orphan")
|
||||
|
||||
class Service(Base):
|
||||
__tablename__ = "services"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
name = Column(String(255), nullable=False)
|
||||
description = Column(Text)
|
||||
price = Column(Float, nullable=False)
|
||||
duration = Column(String(50))
|
||||
image_url = Column(String(500))
|
||||
category = Column(String(100), nullable=False)
|
||||
category_id = Column(String(36), ForeignKey("categories.id"), nullable=True)
|
||||
is_active = Column(Boolean, default=True)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
category_rel = relationship("Category", back_populates="services")
|
||||
bookings = relationship("Booking", back_populates="service")
|
||||
reviews = relationship("Review", back_populates="service", cascade="all, delete-orphan")
|
||||
|
||||
class CartItem(Base):
|
||||
__tablename__ = "cart_items"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
user_id = Column(String(36), ForeignKey("users.id"), nullable=False)
|
||||
product_id = Column(String(36), ForeignKey("products.id"), nullable=False)
|
||||
quantity = Column(Integer, default=1)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
user = relationship("User", back_populates="cart_items")
|
||||
product = relationship("Product", back_populates="cart_items")
|
||||
|
||||
class Order(Base):
|
||||
__tablename__ = "orders"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
user_id = Column(String(36), ForeignKey("users.id"), nullable=False)
|
||||
status = Column(SQLEnum(OrderStatus), default=OrderStatus.PENDING)
|
||||
subtotal = Column(Float, default=0)
|
||||
tax = Column(Float, default=0)
|
||||
shipping = Column(Float, default=0)
|
||||
total = Column(Float, default=0)
|
||||
shipping_address = Column(JSON, default={})
|
||||
notes = Column(Text)
|
||||
tracking_number = Column(String(100))
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
user = relationship("User", back_populates="orders")
|
||||
items = relationship("OrderItem", back_populates="order", cascade="all, delete-orphan")
|
||||
status_history = relationship("OrderStatusHistory", back_populates="order", cascade="all, delete-orphan")
|
||||
|
||||
class OrderItem(Base):
|
||||
__tablename__ = "order_items"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
order_id = Column(String(36), ForeignKey("orders.id"), nullable=False)
|
||||
product_id = Column(String(36), ForeignKey("products.id"), nullable=False)
|
||||
quantity = Column(Integer, default=1)
|
||||
price = Column(Float, nullable=False)
|
||||
product_name = Column(String(255))
|
||||
product_image = Column(String(500))
|
||||
|
||||
order = relationship("Order", back_populates="items")
|
||||
product = relationship("Product", back_populates="order_items")
|
||||
|
||||
class OrderStatusHistory(Base):
|
||||
__tablename__ = "order_status_history"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
order_id = Column(String(36), ForeignKey("orders.id"), nullable=False)
|
||||
status = Column(SQLEnum(OrderStatus), nullable=False)
|
||||
notes = Column(Text)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
created_by = Column(String(36))
|
||||
|
||||
order = relationship("Order", back_populates="status_history")
|
||||
|
||||
class Review(Base):
|
||||
__tablename__ = "reviews"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
user_id = Column(String(36), ForeignKey("users.id"), nullable=False)
|
||||
product_id = Column(String(36), ForeignKey("products.id"), nullable=True)
|
||||
service_id = Column(String(36), ForeignKey("services.id"), nullable=True)
|
||||
rating = Column(Integer, nullable=False) # 1-5
|
||||
title = Column(String(255))
|
||||
comment = Column(Text)
|
||||
is_verified_purchase = Column(Boolean, default=False)
|
||||
is_approved = Column(Boolean, default=True)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
user = relationship("User", back_populates="reviews")
|
||||
product = relationship("Product", back_populates="reviews")
|
||||
service = relationship("Service", back_populates="reviews")
|
||||
|
||||
class Booking(Base):
|
||||
__tablename__ = "bookings"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
service_id = Column(String(36), ForeignKey("services.id"), nullable=False)
|
||||
user_id = Column(String(36), ForeignKey("users.id"), nullable=True)
|
||||
name = Column(String(255), nullable=False)
|
||||
email = Column(String(255), nullable=False)
|
||||
phone = Column(String(50))
|
||||
preferred_date = Column(String(50))
|
||||
notes = Column(Text)
|
||||
status = Column(String(50), default="pending")
|
||||
service_name = Column(String(255))
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
service = relationship("Service", back_populates="bookings")
|
||||
user = relationship("User", back_populates="bookings")
|
||||
|
||||
class Contact(Base):
|
||||
__tablename__ = "contacts"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
name = Column(String(255), nullable=False)
|
||||
email = Column(String(255), nullable=False)
|
||||
subject = Column(String(255))
|
||||
message = Column(Text, nullable=False)
|
||||
status = Column(String(50), default="pending")
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
class InventoryLog(Base):
|
||||
__tablename__ = "inventory_logs"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
product_id = Column(String(36), ForeignKey("products.id"), nullable=False)
|
||||
action = Column(String(50), nullable=False) # add, remove, adjust, sale
|
||||
quantity_change = Column(Integer, nullable=False)
|
||||
previous_stock = Column(Integer)
|
||||
new_stock = Column(Integer)
|
||||
notes = Column(Text)
|
||||
created_by = Column(String(36))
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
product = relationship("Product", back_populates="inventory_logs")
|
||||
|
||||
class SalesReport(Base):
|
||||
__tablename__ = "sales_reports"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=generate_uuid)
|
||||
report_type = Column(String(50), nullable=False) # daily, weekly, monthly
|
||||
report_date = Column(DateTime(timezone=True), nullable=False)
|
||||
start_date = Column(DateTime(timezone=True))
|
||||
end_date = Column(DateTime(timezone=True))
|
||||
total_orders = Column(Integer, default=0)
|
||||
total_revenue = Column(Float, default=0)
|
||||
total_products_sold = Column(Integer, default=0)
|
||||
total_services_booked = Column(Integer, default=0)
|
||||
report_data = Column(JSON, default={})
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
130
archive/techzone-source/backend/requirements.txt
Normal file
130
archive/techzone-source/backend/requirements.txt
Normal file
@@ -0,0 +1,130 @@
|
||||
aiofiles==25.1.0
|
||||
aiohappyeyeballs==2.6.1
|
||||
aiohttp==3.13.3
|
||||
aiosignal==1.4.0
|
||||
annotated-types==0.7.0
|
||||
anyio==4.12.0
|
||||
asyncpg==0.31.0
|
||||
attrs==25.4.0
|
||||
bcrypt==4.1.3
|
||||
black==25.12.0
|
||||
boto3==1.42.21
|
||||
botocore==1.42.21
|
||||
certifi==2026.1.4
|
||||
cffi==2.0.0
|
||||
charset-normalizer==3.4.4
|
||||
click==8.3.1
|
||||
cryptography==46.0.3
|
||||
distro==1.9.0
|
||||
dnspython==2.8.0
|
||||
ecdsa==0.19.1
|
||||
email-validator==2.3.0
|
||||
emergentintegrations==0.1.0
|
||||
fastapi==0.110.1
|
||||
fastuuid==0.14.0
|
||||
filelock==3.20.2
|
||||
flake8==7.3.0
|
||||
frozenlist==1.8.0
|
||||
fsspec==2025.12.0
|
||||
google-ai-generativelanguage==0.6.15
|
||||
google-api-core==2.29.0
|
||||
google-api-python-client==2.187.0
|
||||
google-auth==2.47.0
|
||||
google-auth-httplib2==0.3.0
|
||||
google-genai==1.57.0
|
||||
google-generativeai==0.8.6
|
||||
googleapis-common-protos==1.72.0
|
||||
greenlet==3.3.0
|
||||
grpcio==1.76.0
|
||||
grpcio-status==1.71.2
|
||||
h11==0.16.0
|
||||
hf-xet==1.2.0
|
||||
httpcore==1.0.9
|
||||
httplib2==0.31.0
|
||||
httpx==0.28.1
|
||||
huggingface_hub==1.2.4
|
||||
idna==3.11
|
||||
importlib_metadata==8.7.1
|
||||
iniconfig==2.3.0
|
||||
isort==7.0.0
|
||||
Jinja2==3.1.6
|
||||
jiter==0.12.0
|
||||
jmespath==1.0.1
|
||||
jq==1.10.0
|
||||
jsonschema==4.26.0
|
||||
jsonschema-specifications==2025.9.1
|
||||
librt==0.7.7
|
||||
litellm==1.80.0
|
||||
markdown-it-py==4.0.0
|
||||
MarkupSafe==3.0.3
|
||||
mccabe==0.7.0
|
||||
mdurl==0.1.2
|
||||
motor==3.3.1
|
||||
multidict==6.7.0
|
||||
mypy==1.19.1
|
||||
mypy_extensions==1.1.0
|
||||
numpy==2.4.0
|
||||
oauthlib==3.3.1
|
||||
openai==1.99.9
|
||||
packaging==25.0
|
||||
pandas==2.3.3
|
||||
passlib==1.7.4
|
||||
pathspec==0.12.1
|
||||
pillow==12.1.0
|
||||
platformdirs==4.5.1
|
||||
pluggy==1.6.0
|
||||
propcache==0.4.1
|
||||
proto-plus==1.27.0
|
||||
protobuf==5.29.5
|
||||
psycopg2-binary==2.9.11
|
||||
pyasn1==0.6.1
|
||||
pyasn1_modules==0.4.2
|
||||
pycodestyle==2.14.0
|
||||
pycparser==2.23
|
||||
pydantic==2.12.5
|
||||
pydantic_core==2.41.5
|
||||
pyflakes==3.4.0
|
||||
Pygments==2.19.2
|
||||
PyJWT==2.10.1
|
||||
pymongo==4.5.0
|
||||
pyparsing==3.3.1
|
||||
pytest==9.0.2
|
||||
python-dateutil==2.9.0.post0
|
||||
python-dotenv==1.2.1
|
||||
python-jose==3.5.0
|
||||
python-multipart==0.0.21
|
||||
pytokens==0.3.0
|
||||
pytz==2025.2
|
||||
PyYAML==6.0.3
|
||||
referencing==0.37.0
|
||||
regex==2025.11.3
|
||||
reportlab==4.4.7
|
||||
requests==2.32.5
|
||||
requests-oauthlib==2.0.0
|
||||
rich==14.2.0
|
||||
rpds-py==0.30.0
|
||||
rsa==4.9.1
|
||||
s3transfer==0.16.0
|
||||
s5cmd==0.2.0
|
||||
shellingham==1.5.4
|
||||
six==1.17.0
|
||||
sniffio==1.3.1
|
||||
SQLAlchemy==2.0.45
|
||||
starlette==0.37.2
|
||||
stripe==14.1.0
|
||||
tenacity==9.1.2
|
||||
tiktoken==0.12.0
|
||||
tokenizers==0.22.2
|
||||
tqdm==4.67.1
|
||||
typer==0.21.0
|
||||
typer-slim==0.21.1
|
||||
typing-inspection==0.4.2
|
||||
typing_extensions==4.15.0
|
||||
tzdata==2025.3
|
||||
uritemplate==4.2.0
|
||||
urllib3==2.6.2
|
||||
uvicorn==0.25.0
|
||||
watchfiles==1.1.1
|
||||
websockets==15.0.1
|
||||
yarl==1.22.0
|
||||
zipp==3.23.0
|
||||
1474
archive/techzone-source/backend/server.py
Normal file
1474
archive/techzone-source/backend/server.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user