This project serves as a personal exploration and benchmark of full-stack development skills. It is a full-stack URL shortener application designed to provide a robust and efficient service for creating and managing short URLs. It's built as a monorepo, separating concerns between the client, server, and shared code.
- URL Shortening: Create short, memorable links from long URLs.
- User Authentication: Secure user registration, login, and session management using JWTs and refresh tokens.
- User Management: (Presumed) Functionality to manage user accounts.
- Admin Privileges: (Presumed) Support for different privilege levels (e.g., admin users).
- API: A well-defined API for interacting with the service.
The project leverages modern web technologies for a high-performance and maintainable codebase:
Backend (Server):
- Fastify: A fast and low-overhead web framework for Node.js.
- TypeScript: For type safety and better developer experience.
- SQLite: A lightweight, file-based SQL database for data persistence.
- argon2: For secure password hashing.
- jose: For JSON Web Token (JWT) handling.
- Zod: For runtime validation of API requests.
Frontend (Client):
- SvelteKit: A powerful framework for building web applications with Svelte.
- Svelte 5 (Runes): Utilizing the latest Svelte features for reactive UI development.
- TypeScript: For type safety.
- Vite: A fast build tool for modern web projects.
- Sass: For CSS pre-processing.
Shared (Monorepo Package):
- TypeScript: For shared types, interfaces, and constants.
- Zod: Shared validation schemas for consistent validation across client and server.
The project is organized as a pnpm monorepo with the following main workspaces:
apps/server: Contains the Fastify backend application, handling API requests, database interactions, and business logic.apps/client: Houses the SvelteKit frontend application, providing the user interface.packages/shared: A package containing code shared between the client and server, such as API endpoint constants,zodschemas for data validation, and common TypeScript types.
To get a local copy up and running, follow these simple steps.
-
Clone the repository:
git clone https://github.com/misterabdul/url-shortener.git cd url-shortener -
Install dependencies: This project uses
pnpmworkspaces. Ensure you havepnpminstalled, then run:pnpm install
-
Set up environment variables: Copy the example environment files for both the client and server.
cp apps/client/.env.example apps/client/.env cp apps/server/.env.example apps/server/.env # Edit the .env files with your desired configurations -
Run in development mode: This command will start both the server and client in development mode, with hot-reloading. The Svelte frontend will be accessible at
http://localhost:5173. The Fastify backend will run on the port defined inapps/server/.env(defaulting to 8080 if not specified).pnpm dev
You can build and run this application as a single Docker container.
Navigate to the root of the project and build the Docker image. You can tag it with a meaningful name, for example, url-shortener-app.
docker build -t url-shortener-app .This command will use the Dockerfile in the project root to create a production-ready image for the application.
Once the image is built, you can run a container from it. This command will:
-p 8080:8080: Map port 8080 on your host machine to port 8080 inside the container.-v "$(pwd)"/volumes/data:/app/data: Mount a local directory (volumes/data) to/app/datainside the container for persistent database storage.--env-file ./.env: Load environment variables from your local.envfile into the container.url-shortener-app: Specify the name of the image to run.
docker run -d \
-p 8080:8080 \
-v "$(pwd)"/volumes/data:/app/data \
--env-file ./.env \
url-shortener-appThe application will then be accessible in your web browser, typically at http://localhost:8080.
-
To view logs:
docker logs <container_id_or_name> -f
-
To stop the container:
docker stop <container_id_or_name>
-
To remove the container:
docker rm <container_id_or_name>
(Replace
<container_id_or_name>with the actual ID or name of your running container.)
Transparency is important. This project utilized AI-powered tools, specifically Google's Gemini, to assist in development.
- Documentation: The initial drafts of this
README.mdand theAGENTS.mdfile were generated with AI assistance. - Code Review: The AI was also used to perform code reviews and suggest improvements to the codebase.
The core application logic, architectural decisions, and all final committed code were written and are fully owned by the human developer. The AI's role was that of a supportive tool, not the primary author.
For a detailed breakdown of the principles and nature of this collaboration, please see the AI Agent Contribution file.
This project is licensed under the MIT License. See the LICENSE file for details.