Telegram Mini App Backend
A scalable backend for a Telegram Mini App, built with **Node.js**, **Express**, **TypeScript**, and **PostgreSQL**.
Handles user authentication, referrals, social tasks, check-ins, and in-app tap-game logic.
1.Clone the Repository
git clone https://github.com/Folks-Finance/tg-mini-app-backend-internal
git checkout feat/new
2. Install Dependencies
npm install
3. Configure the Database
* Install and run PostgreSQL on your machine.
* Create a new database:
createdb telegram_mini
* Run the table creation scripts found in `table-query/` or paste your provided `CREATE TABLE` SQL statements in the psql shell:
psql -d telegram_mini
Then run your table creation SQL
---
### 4. **Set Up Environment Variables**
Create a `.env` file at the project root:
DATABASE_URL="postgresql://postgres:<password>@localhost:5432/telegram_mini"
PORT=8000
PRIVY_APP_ID=""
PRIVY_APP_SECRET=""
> Replace `<password>` with your local postgres password.
> Fill in Privy credentials use https://privy.io/
---
### 5. **Start the Development Server**
```bash
npm run dev- This will start the server with
nodemonfor automatic reloads on file changes.
To run in production:
npm run build
npm startAPI endpoints are grouped by feature module. Some examples:
GET /api/user/me— Fetch the authenticated user’s profile.POST /api/user— Register or update a user.GET /api/tasks— List available social tasks.POST /api/checkin— Mark daily/weekly check-in.- More endpoints are available; see
src/modules/for details.
You can use Postman or curl to test your endpoints.
- Database connection errors:
Ensure your
.envis set up and PostgreSQL is running. - Missing tables:
Run all required
CREATE TABLEstatements in your database. - Environment issues:
Double-check
.envand installed dependencies.
- Code is modular: Add features by creating new modules in
src/modules/. - Supports Privy authentication.
- Refer to
src/config/db.tsfor database connection logic. - Extend with new tables using migrations or manual SQL as your app grows.
Contributions, bug reports, and suggestions are welcome! Please open an issue or submit a pull request.
MIT License
- Your Name (@shivam-V8 or GitHub)