obsidian/wiki/client-knowledge/baic.md
2026-05-10 21:14:23 +01:00

75 lines
3 KiB
Markdown

---
title: "BAIC — Client Knowledge"
aliases: [baic-dashboard, baic-deploy]
tags: [client-knowledge, baic, deploy, rsync, azure-ad]
created: 2026-05-06
updated: 2026-05-10
---
# BAIC
BAIC is a Chinese automotive brand. Oliver Agency maintains the BAIC Dashboard — an internal analytics/reporting tool hosted on the main Oliver web server (`baic` SSH alias).
## Key Facts
- **SSH alias**: `baic``vadym.samoilenko@10.220.72.13` (same server as many Oliver projects — see [[wiki/infrastructure/server-baic]])
- **URL**: `https://baic.oliver.solutions/dashboard/`
- **Auth**: Azure AD / Microsoft SSO via MSAL
- **Stack**: React + Vite (frontend) + FastAPI (backend)
## Deploy Process
> [!important] No git on server — deploy via rsync only
```bash
# 1. Build locally
npm run build
# 2. Sync dist/ to server (no git pull on server)
rsync -avz --delete dist/ baic:/var/vhosts/baic.oliver.solutions/htdocs/dashboard/
```
- Remote path: `/var/vhosts/baic.oliver.solutions/htdocs/dashboard/`
- Backend systemd service: `baic_dashboard.service` (underscore, not hyphen)
```bash
# Restart backend after Python changes
ssh baic "sudo systemctl restart baic_dashboard.service"
# Check status
ssh baic "sudo systemctl status baic_dashboard.service"
```
## Deploy Gotchas
| Issue | Detail |
|-------|--------|
| No `.env` file needed | Backend reads env vars with OS defaults directly in `app.py` — do not create `.env` on server |
| rsync "failed to set times" warning | `rsync` warns about directory timestamp permission — **benign**; content copies correctly |
| `deploy.sh` is initial setup only | Script in repo targets first-time setup (wrong service name, interactive prompts) — never use for updates |
| Old Vite hashes accumulate | `assets/` on the server grows with each deploy (old content-hash files never cleaned); manually prune if needed |
## Known Gotchas
| Gotcha | Detail | Article |
|--------|--------|---------|
| FastAPI `root_path` route stripping | Routes must be registered WITHOUT `/dashboard` prefix | [[wiki/concepts/fastapi-root-path-route-stripping]] |
| SSE needs `?token=` | `EventSource` can't set custom headers | [[wiki/concepts/sse-jwt-query-param]] |
| SPA index.html must be no-cache | Old hashes cause blank screen after rebuild | [[wiki/concepts/spa-index-html-cache-control]] |
| MS SSO IDs are not UUIDs | `ms-4n0T2x-...` format breaks UUID validators | [[wiki/concepts/microsoft-sso-non-uuid-ids]] |
## Features
| Feature | Detail | Added |
|---------|--------|-------|
| Per-User Report tab | CSV export for Michael (client stakeholder) — replaces manual Python script previously run ad-hoc | 2026-05-06 |
## Pending
- [ ] Set up git deploy: deploy key → Bitbucket → clone to `/opt/baic_dashboard``update.sh` (eliminates rsync manual step)
## Related
- [[wiki/infrastructure/server-baic]] — server overview (hosts 40+ domains, not just BAIC)
- [[wiki/tech-patterns/azure-ad-msal-auth]] — MSAL SSO pattern
- [[wiki/tech-patterns/react-vite-typescript]] — frontend stack