Page:
EvoSync v3 — Step 1: Environment Setup
Clone
1
EvoSync v3 — Step 1: Environment Setup
mish edited this page 2026-04-27 22:55:40 +03:00
EvoSync v3 — Step 1: Environment Setup
Context
Rebuilding EvoSync from scratch (Python sync platform, Evotor → VK Market). Repo is clean — no web app exists. Goal for this step: scaffold the project skeleton, wire up Docker, and verify all services start healthy with a working DB connection and a live FastAPI app.
Stack
- Backend: FastAPI 0.115 + Uvicorn (Python 3.12)
- Task queue: Celery 5.4 + Redis 7
- Database: MariaDB 11.4 + SQLAlchemy 2.0 + Alembic
- Templates: Jinja2 + Bootstrap 5 CDN
- Monitoring: Celery Flower
What gets created in this step
Root-level files
Dockerfile.web— single image for web/worker/beat/flowerdocker-compose.yml— 6 services: db, redis, web, worker, beat, flowerrequirements.txt— all pinned dependencies.env.example— template with all required varsalembic.ini— points toweb/migrations/
web/ package skeleton
web/
├── __init__.py
├── main.py # FastAPI app, single health route GET /health
├── config.py # pydantic-settings Settings (DATABASE_URL, REDIS_URL, SECRET_KEY, …)
├── database.py # SQLAlchemy engine + SessionLocal + Base
├── models/
│ └── __init__.py # empty for now
├── tasks/
│ ├── __init__.py
│ └── celery_app.py # Celery app factory, broker=REDIS_URL, no beat schedule yet
└── migrations/
├── env.py # Alembic env wired to web.database.Base
├── script.py.mako
└── versions/
└── 0001_initial.py # empty migration (no tables yet)
tests/
tests/
├── conftest.py # SQLite in-memory engine, db_session fixture
└── test_health.py # GET /health returns 200 {"status": "ok"}
docker-compose services
| Service | Image | Port | Command |
|---|---|---|---|
db |
mariadb:11.4 | — | default, healthcheck |
redis |
redis:7-alpine | — | redis-server --save 60 1, healthcheck |
web |
Dockerfile.web | 8080→8000 | alembic upgrade head && uvicorn web.main:app --host 0.0.0.0 --port 8000 |
worker |
Dockerfile.web | — | celery -A web.tasks.celery_app worker --loglevel=info |
beat |
Dockerfile.web | — | celery -A web.tasks.celery_app beat --scheduler celery.beat:PersistentScheduler --schedule /tmp/celerybeat-schedule |
flower |
Dockerfile.web | 5555 | celery -A web.tasks.celery_app flower --port=5555 |
webdepends ondbandredisbeing healthy before startingworkerandbeatdepend onredisbeing healthy- Single
Dockerfile.webimage,command:selects role
Dockerfile.web
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt
COPY . .
CMD ["uvicorn", "web.main:app", "--host", "0.0.0.0", "--port", "8000"]
requirements.txt
fastapi==0.115.5
uvicorn[standard]==0.32.1
python-multipart==0.0.12
jinja2==3.1.4
sqlalchemy==2.0.36
alembic==1.14.0
pymysql==1.1.1
cryptography>=44.0.0
passlib[bcrypt]==1.7.4
bcrypt==4.2.1
pydantic-settings==2.6.1
httpx==0.28.1
celery[redis]==5.4.0
redis==5.2.1
flower==2.0.1
python-json-logger==3.2.1
pytest==8.3.4
pytest-asyncio==0.24.0
pytest-cov==6.0.0
factory-boy==3.3.1
Verification checklist
docker compose up --build→ all 6 services reach healthy/running statecurl http://localhost:8080/health→{"status": "ok"}- Flower at
http://localhost:5555→ shows worker connected docker compose exec web alembic upgrade head→ no errorpytest tests/→test_health.pypasses