|
|
5 miesięcy temu | |
|---|---|---|
| .. | ||
| app | 7 miesięcy temu | |
| scripts | 8 miesięcy temu | |
| tests | 8 miesięcy temu | |
| .dibang-backend.pid | 5 miesięcy temu | |
| .env.production | 8 miesięcy temu | |
| .gitignore | 11 miesięcy temu | |
| README.md | 9 miesięcy temu | |
| env.example | 9 miesięcy temu | |
| env.production.example | 8 miesięcy temu | |
| pyproject.toml | 11 miesięcy temu | |
| start.sh | 11 miesięcy temu | |
This service exposes the HTTP + WebSocket APIs and database access required by the weighbridge system. It targets Python 3.11+.
cd /Users/wuzilong/work/00code/simple-dibang-xiaoshou/backend
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -U pip uv
uv pip install -e ".[dev]"
uv run fastapi dev app/main.py # auto reload server
app/main.py – FastAPI application entrypoint.app/core/config.py – environment-driven settings.app/db/session.py – SQLModel engine/session helpers.app/api/routes – routers grouped by bounded context.app/services – business logic (batch number generation, printing jobs, etc.).tests/ – pytest suites (API, domain, migrations).Copy .env.example to .env and adjust values for your environment.
| Variable | Description | Example |
|---|---|---|
DATABASE_URL |
MySQL database connection string | mysql+asyncmy://user:pass@localhost:3306/dibang?charset=utf8mb4 |
JWT_SECRET |
HS256 secret for signing JWTs (must be strong in production) | your-strong-secret-key-here |
| Variable | Description | Default |
|---|---|---|
ENV |
Environment: dev, test, or prod |
dev |
ACCESS_TOKEN_EXPIRES_MINUTES |
Access token expiration time (minutes) | 60 |
REFRESH_TOKEN_EXPIRES_DAYS |
Refresh token expiration time (days) | 14 |
HOST |
Server bind address | 0.0.0.0 |
PORT |
Server port | 8000 |
CORS_ORIGINS |
Allowed CORS origins (comma-separated, use * for all) |
* |
CORS_ALLOW_CREDENTIALS |
Allow credentials in CORS | true |
CORS_ALLOW_METHODS |
Allowed HTTP methods (comma-separated, use * for all) |
* |
CORS_ALLOW_HEADERS |
Allowed HTTP headers (comma-separated, use * for all) |
* |
DB_POOL_SIZE |
Database connection pool size | 10 |
DB_MAX_OVERFLOW |
Max overflow connections | 20 |
DB_POOL_TIMEOUT |
Connection pool timeout (seconds) | 30 |
DB_POOL_RECYCLE |
Connection recycle time (seconds) | 3600 |
DB_POOL_PRE_PING |
Enable connection pre-ping | true |
See env.example for detailed comments and examples.
ruff check app, ruff format app.mypy app.pytest.alembic revision --autogenerate -m "<msg>".The scaffold follows the architecture plan in frontend_backend_framework_plan.md, making it easy to plug into the new PC and mobile frontends.