|
1 | | -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). |
| 1 | +# Currency Converter |
2 | 2 |
|
3 | | -## Getting Started |
| 3 | +## Project Overview |
| 4 | +This is a currency conversion web application that allows users to input an amount in Australian dollars (AUD) and instantly convert it into five target currencies: USD, EUR, JPY, GBP, and CNY. The interface also provides a 14-day time series chart that visualizes historical exchange rates for the selected currency pair. |
4 | 5 |
|
5 | | -First, run the development server: |
| 6 | +**Tech Stack:** ui:next.js 16 + react 19 + tailwindcss 4 + lucide / data:open exchange rates API / charts:recharts / testing:vitest + testing-library + happy-dom / tooling:pnpm + TypeScript + eslint |
6 | 7 |
|
7 | | -```bash |
8 | | -npm run dev |
9 | | -# or |
10 | | -yarn dev |
11 | | -# or |
12 | | -pnpm dev |
13 | | -# or |
14 | | -bun dev |
15 | | -``` |
16 | 8 |
|
17 | | -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. |
| 9 | +## Quick Start (Local Development) |
| 10 | + |
| 11 | +1. **Clone the repository** |
| 12 | + ```bash |
| 13 | + git clone <repository-url> |
| 14 | + cd currency_converter |
| 15 | + ``` |
| 16 | + |
| 17 | +2. **Install dependencies** |
| 18 | + ```bash |
| 19 | + pnpm install |
| 20 | + ``` |
| 21 | + |
| 22 | +3. **Configure environment variables** |
| 23 | + Create a file named `.env.development` in the project root and specify required credentials. Example: |
| 24 | + ```dotenv |
| 25 | + OXR_BASE_URL=https://openexchangerates.org/api |
| 26 | + OXR_APP_ID=your-openexchangerates-app-id |
| 27 | + ``` |
18 | 28 |
|
19 | | -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. |
| 29 | +4. **Run the development server** |
| 30 | + ```bash |
| 31 | + pnpm dev |
| 32 | + ``` |
20 | 33 |
|
21 | | -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. |
| 34 | +5. **Access the app** |
| 35 | + Navigate to [http://localhost:3000](http://localhost:3000). Hot module replacement is enabled, so the UI updates automatically when you edit files. |
22 | 36 |
|
23 | | -## Learn More |
| 37 | +## Running via Docker (Development) |
24 | 38 |
|
25 | | -To learn more about Next.js, take a look at the following resources: |
| 39 | +1. Ensure Docker is running on your machine. |
| 40 | +2. Copy `.env.development` (with the required `OXR_BASE_URL` and `OXR_APP_ID`) into the project root. |
| 41 | +3. Build and start the dev container using the provided compose file: |
| 42 | + ```bash |
| 43 | + docker compose -f compose.dev.yml up --build |
| 44 | + ``` |
| 45 | +4. Your app will be available at [http://localhost:3000](http://localhost:3000), and code changes on the host filesystem will be hot-reloaded inside the container. |
| 46 | +5. To stop the container, press `Ctrl+C` or run `docker compose -f compose.dev.yml down`. |
26 | 47 |
|
27 | | -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. |
28 | | -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. |
| 48 | +## Deploying with Docker Compose (Production) |
| 49 | + |
| 50 | +1. Prepare a production env file (e.g. `.env.production`) with the required secrets: |
| 51 | + ```dotenv |
| 52 | + OXR_BASE_URL=https://openexchangerates.org/api |
| 53 | + OXR_APP_ID=your-openexchangerates-app-id |
| 54 | + ``` |
| 55 | +2. Build and start the runtime container using the production compose file: |
| 56 | + ```bash |
| 57 | + docker compose -f compose.production.yml up --build -d |
| 58 | + ``` |
| 59 | + This will build the multi-stage Dockerfile and run the `runner` stage, exposing port 3000. |
| 60 | +3. Verify the app at [http://localhost:3000](http://localhost:3000) or on your chosen host. |
| 61 | +4. To inspect logs: |
| 62 | + ```bash |
| 63 | + docker compose -f compose.production.yml logs -f |
| 64 | + ``` |
| 65 | +5. To stop the service: |
| 66 | + ```bash |
| 67 | + docker compose -f compose.production.yml down |
| 68 | + ``` |
| 69 | + |
| 70 | +## Testing |
| 71 | + |
| 72 | +Before running integration tests locally, create a `.env.test` file in the project root with your Open Exchange Rates credentials: |
| 73 | +```dotenv |
| 74 | +OXR_BASE_URL=https://openexchangerates.org/api |
| 75 | +OXR_APP_ID=your-openexchangerates-app-id |
| 76 | +``` |
29 | 77 |
|
30 | | -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! |
| 78 | +1. **Run all tests (unit + integration)** |
| 79 | + ```bash |
| 80 | + pnpm test |
| 81 | + ``` |
31 | 82 |
|
32 | | -## Deploy on Vercel |
| 83 | +2. **Unit tests only** (fast feedback, no external calls) |
| 84 | + ```bash |
| 85 | + pnpm test:unit |
| 86 | + ``` |
33 | 87 |
|
34 | | -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. |
| 88 | +3. **Integration tests only** (hits real OXR API) |
| 89 | + ```bash |
| 90 | + pnpm test:integration |
| 91 | + ``` |
| 92 | + Requires the `.env.test` file (or equivalent environment variables) described above. |
35 | 93 |
|
36 | | -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. |
| 94 | +4. **Continuous integration run with coverage** |
| 95 | + ```bash |
| 96 | + pnpm test:ci |
| 97 | + ``` |
| 98 | + Generates coverage reports under `coverage/`. |
0 commit comments