Skip to content

akshiiitt/share-code-dev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ShareCode

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.


Project Structure

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)

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (running locally or a MongoDB Atlas URI)

Environment Variables

Copy the .env.example in the backend folder to .env and fill in the values.

Backend (backend/.env)

Variable Description Default / Example
MONGODB_URL MongoDB connection URI with DB name mongodb://localhost:27017/sharecode
PORT Port the Node server listens on 8000

Setup & Running

1. Backend (backend)

  1. Navigate to the directory:
    cd backend
  2. Install dependencies:
    npm install
  3. Copy the environment variables template and configure it:
    cp .env.example .env
  4. Start the server (development mode with hot-reloading):
    npm run dev
    The backend will run at http://localhost:8000.

2. Frontend (frontend)

  1. Navigate to the directory:
    cd frontend
  2. Install dependencies:
    npm install
  3. Start the Vite development server:
    npm run dev
    The React app will run at http://localhost:5173.

Git Workflow & Best Practices

To keep the repository clean and record changes correctly:

1. Branching Strategy

  • main: The stable branch. Do not commit directly to main for major changes.
  • Feature Branches: Create descriptive branch names for new features or fixes, e.g., feature/add-syntax-highlighting or bugfix/connection-timeout.

2. Making Commits

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"

About

A minimalist code-sharing application built with React, Express, and MongoDB, featuring automatic 24-hour snippet expiration.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors