Skip to content

Latest commit

 

History

History
89 lines (61 loc) · 1.75 KB

File metadata and controls

89 lines (61 loc) · 1.75 KB

Windows Setup

Recommended versions

  • Python 3.12
  • PostgreSQL 16 for production-like local development
  • Redis through Docker Desktop or WSL2

Python 3.13 may work, but Python 3.12 provides the widest third-party package compatibility.

SQLite quick start

cd enterprise-realtime-chat-api
py -3.12 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -r requirements.txt
Copy-Item .env.example .env

Update .env:

DATABASE_URL=sqlite:///./realtime_chat.db
REDIS_URL=
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
TRUSTED_HOSTS=localhost,127.0.0.1,testserver
UPLOAD_DIR=./uploads
PUBLIC_MEDIA_BASE_URL=http://127.0.0.1:8000/media

Run migrations and seed:

alembic upgrade head
python -m scripts.seed
uvicorn app.main:app --reload

Swagger: http://127.0.0.1:8000/docs

WebSocket: ws://127.0.0.1:8000/ws?token=<ACCESS_TOKEN>

Docker Desktop

Copy-Item .env.example .env
docker compose up --build

Seed:

docker compose exec api python -m scripts.seed

Common errors

Pydantic list parsing

The project accepts either:

CORS_ORIGINS=http://localhost:3000,http://localhost:5173

or:

CORS_ORIGINS=["http://localhost:3000","http://localhost:5173"]

WebSocket connects but receives no group messages

Confirm that the token user is an active conversation member and that Redis is reachable when running more than one API process.

Upload URL points to localhost

Set PUBLIC_MEDIA_BASE_URL to the externally reachable API or CDN origin.

PowerShell blocks activation

For the current terminal only:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\.venv\Scripts\Activate.ps1