# Best Practice Setup for Multi‑App Deployment with Centralized Nginx and Multiple Tornado Backends
This document summarizes the recommended architecture for deploying **multiple React frontends** and **multiple Tornado backends** behind a **single centralized Nginx reverse proxy**, using **Docker Compose** per app, and a **shared nginx-net** for communication.
---
## ✅ 1. Architecture Overview
Each app has:
- Its **own docker-compose.yml**
- Its own **frontend** (e.g., React)
- Its own **backend** (Tornado)
- Both are attached to the **central nginx-net** so Nginx can route to them
- Backend service name may be reused (e.g., `tornado-backend`)
- Backend gets a **unique network alias** for Nginx routing
---
## ✅ 2. URL Namespace Structure (Recommended)
Each app uses a dedicated URL prefix:
```
/<app-name>/ → Frontend
/<app-name>/api/ → Backend API
```
Examples:
### App 1: Blog
```
/aidaho-blog-demo/
/aidaho-blog-demo/api/
```
### App 2: Shop
```
/aidaho-shop/
/aidaho-shop/api/
```
### App 3: Analytics
```
/aidaho-analytics/
/aidaho-analytics/api/
```
This structure:
✅ Prevents routing conflicts
✅ Keeps apps isolated
✅ Works perfectly with React Router
✅ Makes backend routing trivial
---
## ✅ 3. Tornado Backend Routes
Backend should **not include the app prefix**.
Use simple API routes:
```python
(r"/api/get-user-role",GetUserRoleHandler),
(r"/api/login",LoginHandler),
(r"/api/logout",LogoutHandler),
```
The app prefix is handled by **Nginx**, not by the backend.