65 lines
2.2 KiB
Markdown
65 lines
2.2 KiB
Markdown
# URL Shortener
|
|
|
|
A modern, full-stack URL shortener application built with a separate backend and frontend, orchestrated via Docker Compose.
|
|
|
|
## Prerequisites
|
|
|
|
Before you begin, ensure you have the following installed on your machine:
|
|
|
|
- [Docker](https://docs.docker.com/get-docker/)
|
|
- [Docker Compose](https://docs.docker.com/compose/install/)
|
|
|
|
## Configuration
|
|
|
|
1. **Clone the repository:**
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd url-shortener
|
|
```
|
|
|
|
2. **Environment Setup:**
|
|
|
|
Copy the example environment file to create your local configuration:
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
|
|
3. **Configure Environment Variables:**
|
|
|
|
Open the `.env` file and adjust the variables as needed. Key variables include:
|
|
|
|
- `DOMAIN`: The base domain for the application (default: `localhost`).
|
|
- `STACK_NAME`: The name of the Docker stack (default: `url-shortener`).
|
|
- `JWT_SECRET`: A secret key for signing JWTs. **Change this to a secure random string.**
|
|
- `PRISMA_USERNAME` & `PRISMA_PASSWORD`: Credentials for accessing Prisma Studio.
|
|
- Note: `PRISMA_PASSWORD` must be a bcrypt hash. The example file contains the hash for "adminpassword".
|
|
|
|
## Deployment
|
|
|
|
To start the application in a local development environment, run:
|
|
|
|
```bash
|
|
docker compose -f compose.yaml -f compose.local.yaml up -d --build
|
|
```
|
|
|
|
This command builds the images and starts the services in detached mode.
|
|
|
|
### Accessing the Services
|
|
|
|
Once the containers are up and running, you can access the various components at the following URLs (assuming default `DOMAIN=localhost`):
|
|
|
|
- **Frontend (URL Shortener UI):** [http://short.localhost](http://short.localhost)
|
|
- **Backend API:** [http://localhost/api](http://localhost/api)
|
|
- **Prisma Studio (Database GUI):** [http://studio.localhost](http://studio.localhost)
|
|
- *Auth required (default: admin / adminpassword)*
|
|
- **Traefik Dashboard:** [http://traefik.localhost](http://traefik.localhost)
|
|
|
|
## Project Structure
|
|
|
|
The project is organized into two main directories, each with its own README for more detailed information:
|
|
|
|
- **`backend/`**: Contains the Bun API and database logic.
|
|
- **`frontend/`**: Contains the React/Vite frontend application.
|