Study Optimizer
Study Optimizer is a lightweight service that provides scheduling, notifications and bot integrations to help students manage classes and study plans. This repository contains the Zalo bot service (Bun + TypeScript) used by the project.
zalo-bot/— main TypeScript service (Bun runtime) that implements the Zalo bot, webhooks, Prisma models and helper utilities.
- Webhook-based bot for Zalo Official Accounts
- Message processing, broadcast and direct messaging
- Scheduling and notifications for class reminders
- PostgreSQL + Prisma for persistence
- Fast runtime using Bun
- Tests using Bun's test runner
- Bun (https://bun.sh)
- Node-style tooling optional for editors (TypeScript tooling)
- PostgreSQL (or use the provided Docker compose for local dev)
- Open the repository and go to the
zalo-botdirectory:
cd zalo-bot- Install dependencies:
bun install- Create a
.envfile (copy from.env.exampleif available) and set environment variables. Example keys used in the project:
POSTGRES_DB— database namePOSTGRES_USER— database userPOSTGRES_PASSWORD— database passwordPOSTGRES_PORT— database port (default 5432)DATABASE_URL— full connection string (e.g.postgresql://user:pass@localhost:5432/dbname?schema=public)PORT— server port (default 3000)NODE_ENV— environment (development/production)
Zalo-specific variables:
ZALO_BOT_TOKEN— token for bot SDK (keep secret)WEBHOOK_URL— public webhook URL for Zalo callbacksWEBHOOK_SECRET— secret used to validate webhook signaturesZALO_API_BASE_URL— optional base URL for Zalo API (defaults tohttps://openapi.zalo.me)
Note: Do not commit secrets. Use environment variables or a CI secret store.
- Generate Prisma client and push schema (if using local DB):
bun run db:generate
bun run db:push- Run the app (development):
bun run devOr start in production mode:
bun startThis project uses Bun's built-in test runner.
- From
zalo-bot/run:
bun testTests are located under src/__tests__. The repository uses bunfig.toml to preload src/test-setup.ts before running tests; add shared test helpers or global mocks there.
The repository contains helper scripts and docker-compose configurations for local development (see docker-compose-dev.yml). To start the full stack (app + Postgres):
./scripts/docker-dev.sh upAnd to stop:
./scripts/docker-dev.sh down- Add a GitHub Actions workflow that runs
bun installandbun teston pull requests - Add a job to run
bunx @biomejs/biome checkorbun run checkto lint and type-check
src/— TypeScript source filescontrollers/,services/,utils/,routes/,scripts/,types/
prisma/— Prisma schema and seedssrc/__tests__/— unit tests run with Bun
- Fork the repository
- Create a feature branch
- Add tests for new behavior
- Run
bun testand ensure all tests pass - Open a pull request
MIT License - see LICENSE file for details.