- 🔐 Dual Authentication / 雙重認證: Login with Discord OAuth or admin password
- 🚪 Door Control / 門禁控制: Unlock door with automatic 8-second lock timer
- 👥 Role-Based Access / 角色權限: Discord role-based access control
- 🔢 Physical PINs / 實體密碼: Temporary keypad PINs with start/end time windows
- 📋 Access Logging / 存取記錄: Complete audit trail of door access
- 💬 Discord Bot / Discord 機器人: Interactive buttons for door access via Discord
- 🎨 Beautiful UI / 美觀介面: Catppuccin Mocha color palette
- 🔌 GPIO Control / GPIO 控制: Direct Raspberry Pi GPIO control for relay
- Raspberry Pi 5
- Door Lock (power-controlled) / 電控門鎖
- Relay Module / 繼電器模組
- 7-pin Matrix Keypad / 7 pin 矩陣鍵盤
- Power Supply / 電源供應器
- Backend: Node.js, Express, Discord.js
- Frontend: React, Vite
- Database: SQLite
- GPIO: Linux gpiod tools on Raspberry Pi
- Node.js 18+ and pnpm
- Discord Bot Token and OAuth credentials
- Raspberry Pi 5 (for GPIO control)
-
Install dependencies / 安裝相依套件
pnpm install
-
Configure environment / 設定環境變數
cp .env.example .env # Edit .env with your credentials -
Start development server / 啟動開發伺服器
pnpm dev
Visit / 訪問: http://localhost:5173
See .env.example for all configuration options.
Key variables / 主要變數:
DISCORD_CLIENT_ID- Discord OAuth Client IDDISCORD_CLIENT_SECRET- Discord OAuth SecretDISCORD_BOT_TOKEN- Discord Bot TokenDISCORD_KEYPAD_ALERT_CHANNEL_ID- Discord channel for incorrect physical keypad PIN alertsADMIN_PASSWORD- Admin password for web loginRELAY_GPIO_PIN- GPIO pin number (default: 17)KEYPAD_ENABLED- Enable physical keypad scanner on Raspberry PiKEYPAD_GPIO_PINS- GPIO mapping for keypad wires 1..7 (default:27,22,23,24,25,5,6)KEYPAD_SETTLE_MS- Delay after driving each keypad column before reading rows (default:30)KEYPAD_IDLE_RESET_MS- Clear an unfinished keypad entry after inactivity (default:10000)
- Login / 登入 with Discord or admin password
- Unlock Door / 開門 - Click button, auto-locks after 8 seconds
- Admin Panel / 管理面板 (Admin only):
- Add Discord roles for access control
- View access logs
- Physical PINs / 實體密碼:
- Add temporary numeric PINs for the physical keypad
- Default validity is 24 hours
- Set explicit start and end date/time windows
- Creation, revocation, accepted access, and rejected access are audit logged
- Invite bot to your server
- Use
/setup-doorcommand to create unlock button - Click button to unlock door (role check required)
記得設定 API Key,以及需要的話調整 API URL。
https://www.icloud.com/shortcuts/c5ebaa9fb18743599e743dd4cc0fb577
See DEPLOYMENT.md for detailed Raspberry Pi deployment instructions.
# Build frontend
pnpm build
# Start server (serves both API and static files)
NODE_ENV=production pnpm startThe server will serve the frontend at http://localhost:3000 in production mode.
door-mananger/
├── server/ # Backend server
│ ├── db/ # Database functions
│ ├── discord/ # Discord bot
│ ├── gpio/ # GPIO controller
│ └── routes/ # API routes
├── client/ # Frontend React app
│ └── src/
│ ├── components/ # React components
│ └── pages/ # Page components
├── data/ # SQLite database (auto-created)
└── .env.example # Environment template
# Install dependencies
pnpm install
# Run dev server (both frontend & backend)
pnpm dev
# Format code
pnpm format
# Build for production
pnpm build- Always use HTTPS in production / 生產環境務必使用 HTTPS
- Keep credentials secure / 保管好憑證
- Review access logs regularly / 定期檢查存取記錄
- Use strong passwords / 使用強密碼
本專案採用你他媽的想幹嘛就幹嘛公眾授權條款授權,詳情請參閱 LICENSE 檔案。
This project is licensed under the WTFPL License.
The app serves static files directly, but you can use Caddy for automatic HTTPS:
# Install Caddy and use included Caddyfile
sudo apt install caddy
sudo cp Caddyfile /etc/caddy/Caddyfile
sudo systemctl restart caddyCaddy automatically handles SSL certificates with Let's Encrypt!
- Color Palette: Catppuccin Mocha
- Discord: Integration powered by Discord.js
