The backend is a FastAPI application providing a RESTful API and WebSocket support for the Radionica 3D platform.
backend/routers/)auth.py: Login, Registration, Password Reset, and Token management.orders.py: Order creation, tracking, and management.admin.py: High-privileged endpoints for managing users, reviews, and site settings.files.py: Handling uploads and serving protected files (STL models, invoice PDFs).warehouse.py: Inventory management for materials and filaments.backend/services/)We avoid putting heavy logic in routers. Use services instead:
AuditService: Logs every state change (e.g., when an admin changes an order price).FiscalService: Implements the Montenegrin Electronic Fiscalization (EFI). Generates JIKR/IKOF codes and signed XMLs.PricingService: Calculates the quote based on print time, material usage, and fixed costs.The project uses raw SQL for schema definitions (schema.sql) and migrations.
init_db.py (archived in legacy/) was used initially.backend/migrations/ and executed via run_migrations.py.We use a custom dependency get_current_user in backend/auth_utils.py to protect routes.
Example usage:
@router.get("/my-orders")
async def get_orders(current_user: User = Depends(get_current_user)):
return await order_service.get_for_user(current_user.id)
Ensure the virtual environment is activated:
# Windows
backend\.venv\Scripts\activate
Install dependencies: pip install -r backend/requirements.txt
Run with Uvicorn:
python -m uvicorn main:app --app-dir backend --port 8000 --reload
backend/schemas.py.backend/services/.backend/main.py.