davidtran999 commited on
Commit
0bdfe15
·
verified ·
1 Parent(s): b1a8c9c

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +26 -30
README.md CHANGED
@@ -1,49 +1,45 @@
1
  ---
2
  title: Hue Portal Backend
3
- emoji: ⚖️
4
  colorFrom: green
5
  colorTo: blue
6
  sdk: docker
7
- sdk_version: "0.0.1"
8
- app_file: app.py
9
  pinned: false
10
  license: apache-2.0
11
  ---
12
 
13
- ## Authentication & Authorization
14
 
15
- ### Seed tài khoản mặc định
16
 
17
- Sau khi thiết lập môi trường:
18
 
19
- ```bash
20
- cd backend/hue_portal
21
- source ../venv/bin/activate
22
- python manage.py migrate
23
- python manage.py seed_default_users
24
- ```
25
-
26
- Các biến môi trường hỗ trợ tuỳ biến (tùy chọn):
27
 
28
- | Biến | Mặc định |
29
- |------|----------|
30
- | `DEFAULT_ADMIN_USERNAME` | `admin` |
31
- | `DEFAULT_ADMIN_EMAIL` | `admin@example.com` |
32
- | `DEFAULT_ADMIN_PASSWORD` | `Admin@123` |
33
- | `DEFAULT_USER_USERNAME` | `user` |
34
- | `DEFAULT_USER_EMAIL` | `[email protected]` |
35
- | `DEFAULT_USER_PASSWORD` | `User@123` |
36
 
37
- ### API đăng nhập
38
 
39
- - `POST /api/auth/login/` – body `{ "username": "...", "password": "..." }`
40
- - `POST /api/auth/logout/` – body `{ "refresh": "<refresh_token>" }` (header `Authorization: Bearer <access>`)
41
- - `GET /api/auth/me/` lấy thông tin user hiện tại
42
- - `POST /api/auth/register/` chỉ admin gọi được; truyền thêm `role` (`admin` hoặc `user`) khi tạo tài khoản mới.
 
 
 
 
43
 
44
- ### Phân quyền
45
 
46
- - Upload tài liệu (`/api/legal-documents/upload/`) yêu cầu user role `admin` hoặc cung cấp header `X-Upload-Token`.
47
- - Frontend hiển thị nút “Đăng nhập” ở trang chủ và trên thanh điều hướng. Khi đăng nhập thành công sẽ hiển thị tên + role, kèm nút “Đăng xuất”.
48
 
 
 
 
49
 
 
 
1
  ---
2
  title: Hue Portal Backend
3
+ affiliation: Cong An Thanh Pho Hue
4
  colorFrom: green
5
  colorTo: blue
6
  sdk: docker
 
 
7
  pinned: false
8
  license: apache-2.0
9
  ---
10
 
11
+ ## Deployment Notes
12
 
13
+ This Space packages the Django backend (OCR + RAG stack) from the `TryHarDemNayProject` repo. It installs the full backend inside the container and exposes the API on port **7860** via Gunicorn.
14
 
15
+ ### Environment variables required
16
 
17
+ Set the following secrets in **Settings → Repository secrets** before building the Space:
 
 
 
 
 
 
 
18
 
19
+ | Variable | Description |
20
+ |----------|-------------|
21
+ | `DATABASE_URL` | PostgreSQL connection string (Railway instance) with `?sslmode=require`. |
22
+ | `DJANGO_SECRET_KEY` | Secret key for Django. |
23
+ | `DJANGO_ALLOWED_HOSTS` | e.g. `*.hf.space,localhost`. |
24
+ | `DEFAULT_LLM_PROVIDER`, `LLM_PROVIDER`, etc. | Optional overrides reused from the original `.env`. |
 
 
25
 
26
+ You can push these secrets via the helper script:
27
 
28
+ ```bash
29
+ cp ops/hf.secrets.env.example ops/hf.secrets.env
30
+ # edit ops/hf.secrets.env with real values
31
+ export HF_TOKEN=hf_xxx # token with write access to the Space
32
+ python backend/scripts/update_hf_space_secrets.py \
33
+ --space davidttran999/hue-portal-backendDocker \
34
+ --secrets-file ops/hf.secrets.env
35
+ ```
36
 
37
+ ### Startup process
38
 
39
+ `entrypoint.sh` automatically runs:
 
40
 
41
+ 1. `python hue_portal/manage.py migrate`
42
+ 2. `python hue_portal/manage.py createcachetable`
43
+ 3. `gunicorn hue_portal.hue_portal.wsgi:application --bind 0.0.0.0:7860`
44
 
45
+ Logs are streamed in the Space console. If migrations fail because the DB already contains the schema, re-run after fixing credentials or drop the DB manually.