This is the backend service for GitHub Center, built with Node.js, Express.js, MongoDB, and Clerk Authentication.
It provides secure APIs for managing GitHub accounts, repositories, groups, Personal Access Tokens (PAT), and user authentication.
Note: To understand more about the application and to Set up Frontend read README
The backend is responsible for:
- Handling authentication with Clerk.
- Listening to Clerk webhooks to store user information in MongoDB upon registration.
- Integrating with the GitHub API to fetch repository, workflow, and pull request data.
- Managing multiple GitHub accounts per user.
- Organizing repositories into custom groups.
- Storing and encrypting GitHub Personal Access Tokens (PATs).
- User authentication via Clerk.
- Clerk webhook automatically stores new users in MongoDB when they register.
- Secure storage of user data.
- Add, remove, and reset GitHub accounts.
- View detailed information about connected GitHub accounts.
- Create, update, and delete groups.
- Add or remove repositories from groups.
- Create and store encrypted PATs.
- Update PATs or rename them.
- Retrieve stored PAT details securely.
- Fetch repositories from the GitHub API.
- View already selected repositories.
- Add or remove repositories from selection.
- Retrieve PR and workflow details for repositories.
- Node.js + Express.js — REST API framework.
- MongoDB — Database for storing users, groups, accounts, and tokens.
- Clerk — Authentication and user management.
- Ngrok — For local webhook testing.
- Crypto — For encrypting Personal Access Tokens.
- Clone the repository
git clone https://github.com/janisar007/github-center-api.git cd github-center-api
- Install dependencies
npm install
- Environment Variables (.env)
PORT=5000 MONGO_URI=your_mongo_connection_string CLERK_SECRET_KEY=your_clerk_secret_key (start with sk_test) CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key (start with pk_test) CLERK_SIGN_IN_URL=your_clerk_sign_in_url (ie. http://localhost:5173/signin) LOGIN_URL=your_frontend_login_url (ie. http://localhost:5173) ENCRYPTION_KEY=32_character_secret_key (ie. 781w8232d9ed4edfabcf9ed2b1a0eecb0e3tt96d3857f6ef1c53b2cf7a3fc1o5)
Note:
- ENCRYPTION_KEY must be exactly 32 characters for AES-256 encryption.
- CLERK_SIGN_IN_URL and LOGIN_URL must point to your frontend routes.
The backend listens for a Clerk webhook when a new user registers. You can go into configure tab of your application then in the webhook option set up the webhook by using your deplyed / ngrok backend url (ngrok set up is below. it is only for development.)
- User signs up in the frontend via Clerk.
- Clerk sends a POST request to
/create
endpoint with user data. - Backend stores the user in MongoDB if they don't already exist.
Clerk requires a public URL for webhooks.
- Install ngrok
npm install -g ngrok
- Start your backend
npm run start
- Run ngrok to expose your local server
ngrok http 5000
- Copy the ngrok HTTPS URL and set it as your webhook URL in Clerk Dashboard
https://your-ngrok-url.ngrok-free.app/create
- You can persist this ngrok url other wise everytime you expose your port with command 3, you will get a different url
All Rights Reserved © 2025 Janisar Akhtar
This repository and its contents are the property of Janisar Akhtar.
You are free to view, learn and use from the source code, but commercial use is strictly prohibited. Unauthorized use will result in legal action under applicable copyright laws.