2026 NASA 3! Mail Subscription

簽到區 Qwertypig, wen, chilfox

期末 demo 要開 asciiquarium

Meetings

:::spoiler chilfox 05/06

完成事項

三個 latency test,確定原 flush 邏輯不需做更改 測試腳本和測試結果分別份在 progress/chilfox/scriptsprogress/chilfox/latency-test.md 裡面

下週事項

  1. 完成 LDAP TLS 連線設定

  2. 將所有需要 alert mail 的地方設定好

  3. 前端如果有什麼需要我做的事情再跟我說 :::

:::spoiler task

Tasks

Core Auth & Infra

  • 初始化 Django 專案

  • Docker: 設定 PostgreSQL 連線與 .env 架構。

  • 撰寫 Base Models(Alias, TaskQueue)。

  • 實作 POST /api/v1/auth/login/POST /api/v1/auth/logout/

  • ==串接 django-auth-ldap 進行綁定測試,並解析 gidNumber 給予 is_admin 權限。==

  • Session Cookie & CSRF。

  • 設定 DRF 連結 Redis,寫好自訂的 Throttle Class,讓寫 Rate Limit 的可以直接用

APIs & Rate Limit

主要在和 Database 溝通

  • 處理 User & Admin API

  • 設定 Redis,實作 CD

  • 權限處理:Admin API - IsAdminUser,User API - IsAuthenticated

  • 寫入 Database,讓寫 LDAP sync 的可直接用

LDAP sync

  • Mock LDAP

  • 完成同步腳本

:::

Workflow

Do we need webhook on Discord?? -> done

  • 這裡發 issue (可以事先規劃好要做的內容,想到事情就發 issue)

    • label: enhancement for feature, bug for fix

    • [Feature]: xxx, [Bug]: xxx

  • main branch 切出去一個新的 branch

    • feature: feat/xxx

    • bug fix: fix/xxx

    • docs: docs/xxx

  • commit msg:原則跟 branch 差不多

    • 常用的有: feat: xxx, fix: xxx

    • format: style: xxx

    • 另外還有 refactor: xxx, docs: xxx, chore: xxx

  • Pull requests 讓大家知道做了什麼 & 一些技術細節

  • 在 GitHub 上合回 main

    • If conflict, 在本地切到自己的 branch,rebase / merge main

    • 弄好 push 上去,就可以直接合進去 main

  • 如果 branch 不要了,可以刪掉

    • 網站上 /branches 的地方可以刪掉

    • 本地跑 git fetch --prune / git fetch -p 可以刪掉遠端已刪除的 branch

  • 本地 main 上測一下

    • git checkout main -> git pull

:::warning :warning: 記得要寫 Document :::

Job Distribution

subcription_architecture

Layout

Just for reference, subject to change

mail-subscription-backend/
├── .env                        # Environment variables (DB passwords, LDAP URI, etc.)
├── .gitignore                  # Prevents committing .env and __pycache__ to Git
├── docker-compose.yml          # The blueprint that defines and links the 4 services
├── Dockerfile                  # Instructions to build the Python environment
├── requirements.txt            # List of Python packages (Django, DRF, django-q, redis, etc.)
├── manage.py                   # Django's command-line utility
│
├── core/                       # Project-wide settings
│   ├── __init__.py
│   ├── settings.py             # Configures DB, Redis cache, Django-Q broker, and LDAP
│   ├── urls.py                 # Root URL routing (/api/v1/...)
│   └── wsgi.py                 # The entry point for the Django Web service
│
└── apps/                       # Modular Django applications
    ├── __init__.py
    │
    ├── accounts/               # Handles LDAP Authentication & Sessions
    │   ├── __init__.py
    │   ├── apps.py
    │   ├── ldap_config.py      # django-auth-ldap custom logic
    │   ├── views.py            # Login, Logout, Session APIs
    │   └── urls.py             # /api/v1/auth/...
    │
    ├── subscriptions/          # Handles Database Models & API Logic
    │   ├── __init__.py
    │   ├── apps.py
    │   ├── models.py           # Alias and TaskQueue tables
    │   ├── views.py            # User and Admin CRUD endpoints
    │   ├── serializers.py      # JSON payload validation
    │   ├── throttling.py       # Custom Redis-based rate limit logic
    │   └── urls.py             # /api/v1/user/... and /api/v1/admin/...
    │
    └── sync_tasks/             # Handles Django-Q Background Jobs
        ├── __init__.py
        ├── apps.py
        ├── tasks.py            # The actual async functions (sync_ldap, modify_ldap)
        └── ldap_utils.py       # Helper functions for ldapmodify and LDAP pulls

Job1: Basic Structure and Utilities - Qwertypig, 4/8 due

  • initialize git repository

  • write Dockerfile and docker-compose.yml

  • core/settings.py

  • implement /api/v1/auth/* in accounts/

    • django-auth-ldap

    • setup session and csrf

    • DRF permission classes (IsAdminUser, IsAuthenticated)

Job2: Synchronization - chilfox, 4/12 due

  • connect with ldap server using python (ldap_utils.py)

  • modify_ldap: get task from redis/postgresql (tasks.py)

  • configure routine syncing function and retry mechanics

Job3: Database and API - wen, 4/12 user, 4/15 setup and testing

  • database models: define alias table and taskqueue table (models.py)

  • serializers: validate json payloads (serializers.py)

  • api views: implement GET and PUT for APIs

    • update postgres and use async_task('sync_tasks.modify_ldap', task_id)

    • admin api 暫緩?

  • cooldown: DRF throttling class in Redis

suggestions

  • container互ping用內網ip

  • redis速度待觀察

  • 可以demo redis死掉

  • ssh 上 VM 的時候用-A可以forward key,就能git clone了

  • 其中後可以要一個有ACL的帳號

  • 下一次開會(4/15?)討論期中要交的影片內容與錄影片時間