TinyApp is a full-stack web application built with Node.js and Express. It allows users to shorten long URLs, similar to services like bit.ly. This project demonstrates fundamental skills in server-side development, route handling, and session management while implementing features like analytics and user authentication.
- Features
- Getting Started
- Prerequisites
- Installation
- Usage
- Analytics Features
- Project Structure
- Technologies Used
- Contributing
- License
- URL Shortening: Users can create short URLs for any valid web address.
- User Authentication: Registration and login capabilities using encrypted cookies.
- Personalized URL Management: Each user can manage their own URLs (edit/delete).
- Visit Tracking:
- Total Visits: Track the total number of visits to each short URL.
- Unique Visitors: Track the number of unique visitors using cookies.
- Visit Logs: View the full history of visits, including timestamps and visitor IDs.
- Responsive UI: Built with Bootstrap for a clean and responsive design.
- Error Handling: Graceful error messages for invalid actions or inaccessible routes.
Follow these instructions to get a copy of TinyApp up and running on your local machine.
-
Clone this repository:
git clone https://github.com/ArcaneCipher/tinyapp.git cd tinyapp
-
Install dependencies:
npm install
-
Start the development server:
npm start
-
Visit the app in your browser at:
http://localhost:8080
- Register:
- Navigate to
/register
to create an account.
- Navigate to
- Log In:
- Navigate to
/login
to sign in and access your personalized URL dashboard.
- Navigate to
- Create a Short URL:
- Click "Create New URL" to shorten a long URL.
- Manage URLs:
- Edit or delete your short URLs from the dashboard.
- Share Short URLs:
- Share the generated short URL with others for redirection.
TinyApp provides in-depth analytics for each URL:
- Visit Count: Displays the total number of visits for each short URL.
- Unique Visitors: Tracks distinct users using cookies to provide a unique count.
- Visit Log: Records each visit with a timestamp and a randomly generated visitor ID.
tinyapp/
├── docs/
│ ├── dashboard.png # View of /urls showing all user URLs
│ ├── details.png # View of /urls:id short URL details
│ ├── login.png # View of /login screen
├── test/ # Testing using mocha/chai
│ ├── helpersTest.js # Tests for server Helper functions
├── views/ # EJS templates
│ ├── partials/ # Reusable partial templates (header, footer)
| | ├── _header.ejs # header template for views
│ ├── urls_index.ejs # Dashboard for URLs
│ ├── urls_new.ejs # Form for creating new URLs
│ ├── urls_show.ejs # URL details with analytics
│ ├── login.ejs # Login form
│ ├── register.ejs # Registration form
│ ├── error.ejs # Clean HTML error page
├── .gitignore # gitignore to ignore node_modules
├── helpers.js # Helper functions for the server
├── express_server.js # Main server file
├── package.json # Dependencies and scripts
├── package-lock.json # Dependencies and scripts
└── README.md # Project documentation
- Backend:
- Node.js
- Express.js
- Frontend:
- EJS (Embedded JavaScript templates)
- Bootstrap
- Authentication:
cookie-session
for session managementbcrypt
for password hashing
- Analytics:
- Session cookies for tracking unique visitors
Contributions are welcome! If you'd like to contribute, please:
- Fork this repository.
- Create a new branch (
git checkout -b feature-name
). - Commit your changes (
git commit -m 'Add new feature'
). - Push the branch (
git push origin feature-name
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE
file for more details.