A Git-Inspired Version Control System Built from Scratch
Features β’ Tech Stack β’ Installation β’ Usage β’ API Documentation
GitForge is an educational project that recreates Git's core functionality from the ground up to understand how version control systems work internally. It implements fundamental Git commands like init, add, commit, push, pull, and revert, while leveraging AWS S3 for remote storage instead of traditional Git servers.
This project combines a CLI tool for local version control operations with a full-stack web application for repository management, user authentication, and collaboration features.
- Learn Git Internals: Understand how Git tracks changes, creates commits, and manages file snapshots
- Cloud Storage Integration: Use AWS S3 as a remote repository storage solution
- Full-Stack Development: Build a complete ecosystem with CLI tools and web interface
- Real-World Application: Implement authentication, authorization, and collaboration features
init- Initialize a new GitForge repository (.gitForgedirectory)add <file>- Stage files for commit (move to staging area)commit <message>- Create a snapshot with unique commit ID (UUID)push- Upload commits to AWS S3 bucketpull- Download commits from AWS S3 bucketrevert <commitID>- Revert repository to a specific commit
-
User Management
- User registration and authentication (JWT-based)
- User profiles with activity heatmaps
- Password encryption with bcrypt
-
Repository Management
- Create and manage repositories
- Public/private visibility settings
- Star repositories
- Repository content browsing
-
Issue Tracking
- Create and manage issues
- Link issues to repositories
- Issue collaboration
-
Real-time Features
- WebSocket integration with Socket.IO
- Live updates and notifications
| Technology | Purpose |
|---|---|
| UI library | |
| Build tool & dev server | |
| Client-side routing | |
| Utility-first CSS framework | |
| HTTP client | |
| GitHub's design system |
GitForge/
βββ backend/
β βββ config/
β β βββ aws-config.js # AWS S3 configuration
β βββ controllers/
β β βββ init.js # Initialize repository
β β βββ add.js # Stage files
β β βββ commit.js # Create commits
β β βββ push.js # Upload to S3
β β βββ pull.js # Download from S3
β β βββ revert.js # Revert to commit
β β βββ userController.js # User operations
β β βββ repoController.js # Repository operations
β β βββ issueController.js # Issue operations
β βββ middleware/
β β βββ authMiddleware.js # JWT authentication
β β βββ authorizeMiddleware.js # Authorization checks
β βββ models/
β β βββ userModel.js # User schema
β β βββ repoModel.js # Repository schema
β β βββ issueModel.js # Issue schema
β βββ routes/
β β βββ user.router.js # User endpoints
β β βββ repo.router.js # Repository endpoints
β β βββ issue.router.js # Issue endpoints
β βββ index.js # Entry point & CLI
β βββ package.json
β
βββ frontend/
βββ src/
β βββ components/
β β βββ auth/ # Login & Signup
β β βββ dashboard/ # Main dashboard
β β βββ repo/ # Repository components
β β βββ user/ # User profile & heatmap
β β βββ issue/ # Issue components
β βββ authContext.jsx # Auth state management
β βββ ProjectRoutes.jsx # Route configuration
β βββ App.jsx
βββ package.json
- Node.js (v16 or higher)
- MongoDB (local or Atlas)
- AWS Account with S3 bucket access
- Git (for cloning the repository)
git clone https://github.com/prathampmp23/GitForge-Backend
cd GitForgecd backend
npm installCreate a .env file in the backend directory:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/gitforge
JWT_SECRET=your_jwt_secret_key_here
# AWS Configuration
AWS_REGION=your-aws-region
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
S3_BUCKET=your-s3-bucket-namecd ../frontend
npm installCreate a .env file in the frontend directory (if needed):
VITE_API_URL=http://localhost:3000- Create an S3 bucket in your AWS account
- Configure IAM user with S3 access permissions
- Update the
.envfile with your credentials
Start Backend Server:
cd backend
npm startServer will run on http://localhost:3000
Start Frontend Dev Server:
cd frontend
npm run devFrontend will run on http://localhost:5173
Navigate to any directory where you want to use GitForge:
Initialize a Repository:
node backend/index.js initAdd Files to Staging:
node backend/index.js add myfile.txtCommit Changes:
node backend/index.js commit "Initial commit"Push to S3:
node backend/index.js pushPull from S3:
node backend/index.js pullRevert to a Commit:
node backend/index.js revert <commit-id>When you run init, GitForge creates a .gitForge directory with:
.gitForge/
βββ config.json # Configuration (S3 bucket name)
βββ commits/ # Stores all commits locally
βββ staging/ # Temporary area for files to be committed
The add command copies files from your working directory to the .gitForge/staging area.
The commit command:
- Generates a unique UUID for the commit
- Creates a new directory under
.gitForge/commits/<uuid>/ - Copies all files from staging to the commit directory
- Saves metadata in
commit.json(message, timestamp)
The push command:
- Reads all commit directories
- Uploads each file to S3 with the structure:
commits/<commit-id>/<filename> - Uses AWS SDK for file transfer
Downloads commits from S3 back to local .gitForge/commits directory.
Restores your working directory to the state of a specific commit.
POST /auth/register - Register new user
POST /auth/login - Login user (returns JWT token)
GET /auth/profile - Get current user profile
POST /repos - Create new repository
GET /repos - Get all repositories
GET /repos/:id - Get repository by ID
PUT /repos/:id - Update repository
DELETE /repos/:id - Delete repository
POST /repos/:id/star - Star/unstar a repository
POST /repos/:repoId/issues - Create issue
GET /repos/:repoId/issues - Get all issues
GET /issues/:id - Get issue by ID
PUT /issues/:id - Update issue
DELETE /issues/:id - Delete issue
By building GitForge, you'll understand:
- β Version Control Internals: How Git tracks file changes using snapshots
- β File System Operations: Reading, writing, and managing directories in Node.js
- β Cloud Storage: Integrating AWS S3 for persistent storage
- β CLI Development: Building command-line tools with Yargs
- β Full-Stack Architecture: Connecting frontend, backend, and cloud services
- β Authentication: Implementing JWT-based auth with bcrypt
- β Real-time Communication: Using WebSockets with Socket.IO
- β Database Design: Modeling relationships with MongoDB and Mongoose
Contributions are welcome! Feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the ISC License.
- Inspired by the internal workings of Git
- Built as an educational project to understand version control systems
- Thanks to the open-source community for the amazing tools and libraries
Project Maintainer: Pratham Potdar
- GitHub: @prathampmp23
Made with β€οΈ to understand Git better
β Star this repo if you found it helpful!