A responsive, full-stack URL shortener application built with React and Node.js, inspired by Bitly.
Run the following command from the project root to install all dependencies:
npm run install-allThis will install dependencies for:
The application uses SQLite by default, so no database URL configuration is needed for basic setup. The database file will be automatically created in server/data/LinkX.db.
If you want to use a different database (PostgreSQL or MongoDB), you can configure it in server/.env:
cd server
cp .env.example .envThen edit server/.env and uncomment/configure the database settings you need.
From the project root, run:
npm run devThis will start both the backend server (port 5000) and frontend development server (port 3000).
Alternatively, you can run them separately:
Terminal 1 - Backend:
npm run serverTerminal 2 - Frontend:
npm run client- Open your browser and navigate to
http://localhost:3000 - Paste a long URL in the input field
- Optionally, click "Custom Code" to set a custom short code
- (Optional) Click "Expire/Limit" to set an expiration date or max clicks
- Click "Shorten URL"
- Copy and share your shortened URL!
Create a new short URL
{
"originalUrl": "https://example.com/very/long/url",
"customCode": "optional-custom-code"
}Get all shortened URLs (with limit query param)
Get URL details by short code
Redirect to original URL (increments click count)
Get statistics for a short URL
linkx/
├── client/ # React frontend
│ ├── public/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── App.js
│ │ └── index.js
│ └── package.json
├── server/ # Express backend
│ ├── data/ # SQLite database (auto-created)
│ ├── routes/ # API routes
│ ├── database.js # Database configuration
│ ├── index.js # Server entry point
│ └── package.json
├── package.json # Root package.json
└── README.md
The application uses SQLite by default. The database file is automatically created at server/data/linkx.db when you first run the server. No additional configuration needed!
If you want to use PostgreSQL instead:
- Install PostgreSQL and create a database
- Update
server/.env:DB_TYPE=postgresql DB_HOST=localhost DB_PORT=5432 DB_NAME=linkx DB_USER=your_username DB_PASSWORD=your_password - Update
server/database.jsto use PostgreSQL client (pg)
If you want to use MongoDB:
- Install MongoDB and start the service
- Update
server/.env:DB_TYPE=mongodb DB_CONNECTION_STRING=mongodb://localhost:27017/linkx - Update
server/database.jsto use MongoDB client (mongodb)
Create server/.env file (optional, defaults work fine):
PORT=5000
BASE_URL=http://localhost:5000For frontend, create client/.env (optional):
REACT_APP_API_URL=http://localhost:5000/apiTo build the frontend for production:
cd client
npm run buildThe production build will be in client/build/.
MIT