Add initial setup for frontend and backend
This commit includes configurations and boilerplate code for both frontend and backend. The frontend uses Next.js with Tailwind CSS, while the backend is built with FastAPI. Various essential files like `tsconfig.json`, `requirements.txt`, and `.gitignore` have been added to kickstart the development process.
This commit is contained in:
0
backend/app/__init__.py
Normal file
0
backend/app/__init__.py
Normal file
29
backend/app/config.py
Normal file
29
backend/app/config.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from pydantic_settings import BaseSettings
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
PROJECT_NAME: Optional[str] = "EventSpace"
|
||||
VERSION: Optional[str] = "1.0.0"
|
||||
API_V1_STR: Optional[str] = "/api/v1"
|
||||
|
||||
# Database configuration
|
||||
DATABASE_URL: Optional[str] = None
|
||||
|
||||
# JWT configuration
|
||||
SECRET_KEY: Optional[str] = None
|
||||
ALGORITHM: Optional[str] = "HS256"
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES: Optional[int] = 30
|
||||
|
||||
# CORS configuration
|
||||
BACKEND_CORS_ORIGINS: Optional[List[str]] = ["http://localhost:3000"] # Frontend URL
|
||||
|
||||
# Admin user
|
||||
FIRST_SUPERUSER_EMAIL: Optional[str] = None
|
||||
FIRST_SUPERUSER_PASSWORD: Optional[str] = None
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
|
||||
|
||||
settings = Settings()
|
||||
0
backend/app/core/__init__.py
Normal file
0
backend/app/core/__init__.py
Normal file
20
backend/app/core/database.py
Normal file
20
backend/app/core/database.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
import os
|
||||
|
||||
SQLALCHEMY_DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@db:5432/eventspace")
|
||||
|
||||
engine = create_engine(SQLALCHEMY_DATABASE_URL)
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
# Dependency to get DB session
|
||||
def get_db():
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
36
backend/app/main.py
Normal file
36
backend/app/main.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import HTMLResponse
|
||||
|
||||
from app.config import settings
|
||||
|
||||
app = FastAPI(
|
||||
title=settings.PROJECT_NAME,
|
||||
version=settings.VERSION,
|
||||
openapi_url=f"{settings.API_V1_STR}/openapi.json"
|
||||
)
|
||||
|
||||
# Set up CORS middleware
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=settings.BACKEND_CORS_ORIGINS,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def root():
|
||||
return """
|
||||
<html>
|
||||
<head>
|
||||
<title>EventSpace API</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome to EventSpace API</h1>
|
||||
<p>Explore the available endpoints and documentation:</p>
|
||||
<a href="/docs">OpenAPI Documentation</a>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
44
backend/requirements.txt
Normal file
44
backend/requirements.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
# Core FastAPI framework and dependencies
|
||||
fastapi>=0.115.8
|
||||
uvicorn>=0.34.0
|
||||
pydantic>=2.10.6
|
||||
pydantic-settings>=2.2.1
|
||||
python-multipart>=0.0.19
|
||||
|
||||
# Database
|
||||
sqlalchemy>=2.0.29
|
||||
alembic>=1.14.1
|
||||
psycopg2-binary>=2.9.9
|
||||
asyncpg>=0.29.0
|
||||
|
||||
# Security and authentication
|
||||
python-jose>=3.4.0
|
||||
passlib>=1.7.4
|
||||
bcrypt>=4.1.2
|
||||
python-dotenv>=1.0.1
|
||||
|
||||
# API documentation
|
||||
email-validator>=2.1.0.post1
|
||||
ujson>=5.9.0
|
||||
|
||||
# CORS support
|
||||
starlette>=0.40.0
|
||||
starlette-csrf>=1.4.5
|
||||
|
||||
# Utilities
|
||||
httpx>=0.27.0
|
||||
tenacity>=8.2.3
|
||||
pytz>=2024.1
|
||||
pillow>=10.3.0
|
||||
|
||||
# Testing
|
||||
pytest>=8.0.0
|
||||
pytest-asyncio>=0.23.5
|
||||
pytest-cov>=4.1.0
|
||||
requests>=2.32.0
|
||||
|
||||
# Development tools
|
||||
black>=24.3.0
|
||||
isort>=5.13.2
|
||||
flake8>=7.0.0
|
||||
mypy>=1.8.0
|
||||
Reference in New Issue
Block a user