A modern URL shortener application with analytics capabilities. Shorten long URLs, track click metrics, and gain insights into how your links are performing.
- 🔗 URL shortening with custom aliases
- 📊 Detailed analytics and tracking
- 👤 User authentication with roles (Admin & User)
- 🔒 Admin panel for user management and app settings
- 🔔 In-app notifications system
- 🌐 Multilingual support (English & Spanish)
- 🌓 Dark/Light theme
- 📱 Responsive design
- 🔒 Secure link management
- Frontend: React, TypeScript, TailwindCSS, shadcn/ui
- Backend: Supabase (PostgreSQL, Authentication, Edge Functions)
- State Management: React Query, Context API
- i18n: React-i18next
- Deployment: Docker
- Node.js 16+ and npm
- Docker and Docker Compose (for containerized deployment)
- Supabase account for backend services
- Clone the repository
git clone https://github.com/your-username/url-shortener.git
cd url-shortener
- Install dependencies
npm install
- Set up environment variables
Create a .env
file in the root directory:
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
- Start the development server
npm run dev
The application will be available at http://localhost:8080
.
- Set up environment variables
Create a .env
file with your Supabase credentials:
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_anon_key
- Build and run with Docker Compose
docker-compose up -d
The application will be available at http://localhost:8080
.
url-shortener/
├── src/ # Source files
│ ├── components/ # Reusable components
│ │ └── admin/ # Admin panel components
│ ├── hooks/ # Custom React hooks
│ ├── pages/ # Page components
│ ├── context/ # Context providers
│ ├── utils/ # Utility functions
│ ├── locales/ # i18n translations
│ ├── integrations/ # Third-party service integrations
│ └── lib/ # Library code and helpers
├── public/ # Static assets
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── README.md # Project documentation
└── package.json # Project dependencies and scripts
The application uses the following database tables in Supabase:
-
urls: Stores shortened URLs and their metadata
id
: UUID, primary keyoriginal_url
: Text, the original long URLshort_code
: Text, auto-generated short codecustom_alias
: Text, optional user-defined aliascreated_at
: Timestamp, when the URL was createduser_id
: UUID, foreign key to auth.usersclicks
: Integer, number of times the URL was accessed
-
analytics: Stores URL access analytics
id
: UUID, primary keyurl_id
: UUID, foreign key to urlstimestamp
: Timestamp, when the URL was accesseduser_agent
: Text, the browser/device infoip
: Text, visitor IP address (hashed)country
: Text, visitor country based on IP
-
profiles: Stores user profiles and roles
id
: UUID, primary key, foreign key to auth.usersusername
: Text, optional usernamerole
: Enum ('USER', 'ADMIN'), user roleis_active
: Boolean, whether user account is activecreated_at
: Timestamp, when the profile was created
-
notifications: Stores user notifications
id
: UUID, primary keyuser_id
: UUID, foreign key to auth.userstitle
: Text, notification titlemessage
: Text, notification contentread
: Boolean, whether notification has been readcreated_at
: Timestamp, when the notification was created
-
app_settings: Stores application settings
id
: UUID, primary keykey
: Text, setting keyvalue
: JSONB, setting valueupdated_at
: Timestamp, when the setting was last updatedupdated_by
: UUID, foreign key to auth.users
-
USER: Can create and manage their own shortened URLs
- Access to personal dashboard with URL statistics
- Cannot access admin features
- Cannot see other users' data
-
ADMIN: Full system access
- All USER permissions
- Access to Admin Panel
- View and manage all users (enable/disable, change roles)
- Send notifications to users
- Configure application settings
The application supports multiple languages:
- English (default)
- Spanish
Users can switch languages via the language selector in the navbar.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Project Link: https://github.com/your-username/url-shortener