ShareCode is a web application that allows users to instantly share code snippets. Users can write/paste code, share it to generate a unique link, and edit existing snippets.
The repository is structured as follows:
backend: Node.js backend built with Express and Mongoose (connected to MongoDB).frontend: React frontend built with Vite and Tailwind CSS.
Snippets automatically expire and are cleaned up from the database 24 hours after creation using a 24-hour MongoDB TTL index.
sharecode/
├── backend/ # Express Node.js backend (Port 8000)
├── frontend/ # React + Vite frontend (Port 5173)
├── .gitignore # Root Git ignore rules
└── README.md # Project documentation (this file)
- Node.js (v18 or higher)
- MongoDB (running locally or a MongoDB Atlas URI)
Copy the .env.example in the backend folder to .env and fill in the values.
| Variable | Description | Default / Example |
|---|---|---|
MONGODB_URL |
MongoDB connection URI with DB name | mongodb://localhost:27017/sharecode |
PORT |
Port the Node server listens on | 8000 |
- Navigate to the directory:
cd backend - Install dependencies:
npm install
- Copy the environment variables template and configure it:
cp .env.example .env
- Start the server (development mode with hot-reloading):
The backend will run at
npm run dev
http://localhost:8000.
- Navigate to the directory:
cd frontend - Install dependencies:
npm install
- Start the Vite development server:
The React app will run at
npm run dev
http://localhost:5173.
To keep the repository clean and record changes correctly:
main: The stable branch. Do not commit directly tomainfor major changes.- Feature Branches: Create descriptive branch names for new features or fixes, e.g.,
feature/add-syntax-highlightingorbugfix/connection-timeout.
We follow the Conventional Commits standard:
feat: ...— for new features.fix: ...— for bug fixes.docs: ...— for documentation additions/changes.chore: ...— for project setup, dependency updates, or configuration.
Example commit command:
git commit -m "docs: add root README and gitignore config"