Skip to content

avishek0769/My_Github

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

My GitHub

A self-hosted Git server and custom web UI inspired by GitHub.

This project was built to understand the fundamentals of how a Git hosting platform works: auth, per-user namespaces, repository creation, SSH key setup, and browsing code/history through a web interface.

Live website: My Github

What is implemented

Core Git hosting flow

  • Per-user namespaces (repositories live under username/repo.git)
  • Bare repository creation from the web UI
  • Clone URL generation in SSH format: git@host:username/repo.git
  • Push and pull workflow via SSH once keys are configured

Authentication and accounts

  • Signup and login
  • JWT-based session handling
  • Password hashing with bcryptjs
  • Account page for SSH key management

SSH key management

  • Add/list/delete public keys from the UI
  • Stores user keys in each user's .ssh/authorized_keys
  • Attempts to mirror keys into system git user authorized keys (/home/git/.ssh/authorized_keys)

Repository and code browsing UI

  • Explore users and their repository counts
  • User repository listing
  • Branch-aware repository view
  • File tree browsing
  • File content viewer with syntax highlighting
  • README rendering on repository root

Commit history and diffs

  • Commit list grouped by date
  • Commit detail metadata (author, date, parent)
  • File-level change stats (additions/deletions)
  • Inline patch/diff display per changed file

Tech stack

  • Backend: Express, simple-git, CORS, jsonwebtoken, bcryptjs
  • Frontend: React, React Router, Vite, Tailwind CSS, Lucide icons

Project structure

.
├── backend/
│   ├── app.js
│   └── package.json
├── client/
│   ├── src/
│   │   ├── components/
│   │   ├── context/
│   │   ├── pages/
│   │   ├── services/
│   │   ├── App.jsx
│   │   ├── config.js
│   │   └── main.jsx
│   └── package.json
└── README.md

Local development

1. Backend

cd backend
pnpm install
node app.js

Default backend URL: http://localhost:3000

2. Frontend

cd client
pnpm install
pnpm dev

Default frontend URL: http://localhost:5173

Configuration

Frontend config

Edit client/src/config.js:

  • API_BASE_URL: backend base URL used by the frontend
  • GIT_SERVER_HOST: host used in generated clone URLs
  • APP_TITLE: UI title in header

Backend constants

backend/app.js currently defines:

  • PORT: API port (default 3000)
  • ORIGIN: allowed frontend origin for CORS
  • GIT_BASE: filesystem root used to store users and bare repos
  • JWT_SECRET: JWT signing secret

For production, move these values to environment variables.

API routes

Base path: /api

Auth

  • POST /api/auth/signup
  • POST /api/auth/login
  • GET /api/auth/me

Account (SSH keys)

  • GET /api/account/ssh-keys
  • POST /api/account/ssh-keys
  • DELETE /api/account/ssh-keys/:keyId

Users

  • GET /api/users

Repositories

  • GET /api/:username/repos
  • GET /api/:username/repo/exists/:name
  • POST /api/:username/repo/create
  • GET /api/:username/:repoName/info
  • GET /api/:username/:repoName/tree
  • GET /api/:username/:repoName/blob
  • GET /api/:username/:repoName/commits
  • GET /api/:username/:repoName/commits/:hash

Security notes

This project is intentionally lightweight for learning.

Before serious/public deployment, add at least:

  • Environment-based secrets and host paths
  • Strong input validation and rate limiting
  • Tightened CORS and auth hardening
  • Operational hardening around SSH key write permissions

Scripts

Backend

  • node app.js

Frontend

  • pnpm dev
  • pnpm build
  • pnpm preview
  • pnpm lint

License

MIT

About

Custom self-hosted Git platform with SSH push/clone, repository browser, commit history, and web-based repo management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages