A full-stack URL Shortener application built with a Node.js Express backend and a React frontend, using MongoDB as the database and Redis for caching and rate-limiting. This project supports Docker for easy deployment and environment setup.
- Shorten long URLs with rate-limiting to prevent abuse.
- User authentication (register, login) with JWT-based authorization.
- Dashboard to manage and view your shortened URLs.
- RESTful API for backend services.
- Dockerized setup for quick local development and deployment.
.
├── backend # Backend API (Node.js/Express)
│ ├── src
│ │ ├── config # Configuration files (database, rate limiter)
│ │ ├── controllers # API route controllers
│ │ ├── middleware # Custom middleware (auth, etc.)
│ │ ├── models # Mongoose models (User, URL)
│ │ ├── routes # API routes
│ │ ├── utils # Utility functions (logging, validation)
│ └── tsconfig.json # TypeScript configuration
├── docker-compose.yml # Docker Compose configuration
├── frontend # Frontend application (React)
│ ├── src
│ │ ├── components # Reusable components (forms, auth)
│ │ ├── pages # Application pages (dashboard, home, etc.)
│ │ ├── services # API services for backend communication
│ │ ├── utils # Utility functions (e.g., token management)
│ └── tsconfig.json # TypeScript configuration
- Docker and Docker Compose installed on your system.
- Node.js and npm (optional, if running services locally without Docker).
git clone git@github.com:Daniyal-j/URLite.git
cd URLite- The project uses environment variables to manage configuration. Copy the provided
.env.examplefiles in bothbackendandfrontendand fill in the required values.
MONGO_URI=mongodb://mongo:27017/URLite
REDIS_URL=redis://redis:6379
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX=50
RATE_LIMIT_MESSAGE="Too many URL shortening requests, please try again later"
BASE_URL=http://localhost:8000
JWT_SECRET="your-secret-key"
PORT=8000REACT_APP_BASE_URL=http://localhost:8000docker-compose up --build- Access the frontend at
http://localhost:3000. - The backend API is available at
http://localhost:8000.
- Navigate to the
backenddirectory:cd backend - Install dependencies:
npm install
- Start the backend server:
npm run dev
- Navigate to the
frontenddirectory:cd frontend - Install dependencies:
npm install
- Start the React development server:
npm start
- POST
/auth/register- Register a new user. - POST
/auth/login- Log in and retrieve a JWT token.
- POST
/urls/shorten- Shorten a URL (rate-limited). - GET
/urls- Retrieve all URLs for an authenticated user.
- Node.js, Express.js, TypeScript
- MongoDB with Mongoose
- Redis for caching and rate-limiting
- JWT for authentication
- React, TypeScript
- Axios for API calls
- Tailwind CSS (optional, if used for styling)
- Docker and Docker Compose for containerization