### Accessing Guides via HTTP GET Requests
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
Demonstrates how to access English and Japanese guides using curl. It also shows how to simulate auto-redirect based on the browser's Accept-Language header.
```bash
curl -X GET "http://localhost:8000/guide/"
# Japanese guide
curl -X GET "http://localhost:8000/ja/guide/"
# Auto-redirect based on browser language
curl -X GET "http://localhost:8000/guide/" \
-H "Accept-Language: ja-JP,ja;q=0.9,en;q=0.8"
# Response: 302 Redirect to /ja/guide/
```
--------------------------------
### Start Development Server (Bash)
Source: https://github.com/syaryn/stock_back_calc/blob/main/README.md
Command to start the development server for the Stock Target Price Calculator. Requires Deno or Mise to be installed. The server will be accessible at http://localhost:8000.
```bash
mise run start
# or
deno task start
```
--------------------------------
### Access Guide Page (Bash)
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
This entry represents the documentation for accessing the static guide page. While no code snippet is provided in the input text for this specific route, it is documented as a GET request to '/guide/'. This page explains the calculator's functionality and underlying financial theories.
```bash
# Accessing the static guide page
# curl -X GET "http://localhost:8000/guide/"
```
--------------------------------
### Manage Development and Testing Tasks
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
Shell commands for managing the Deno development environment, including starting the server and executing test suites with coverage and specific file filtering.
```bash
deno task dev
mise run start
deno task test
deno task check
deno test --allow-read --allow-env --allow-net utils/pricing_test.ts
deno test --allow-read --allow-env --allow-net main_test.ts
```
--------------------------------
### GET /
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
The main calculator interface. Accepts query parameters to pre-populate calculation fields and supports internationalization via headers and cookies.
```APIDOC
## GET /
### Description
Serves the main calculator interface. Supports pre-population of stock data via query parameters and handles language localization based on browser headers or cookies.
### Method
GET
### Endpoint
/
### Parameters
#### Query Parameters
- **stockPrice** (number) - Optional - Current market price of the stock
- **currentPer** (number) - Optional - Current Price-to-Earnings ratio
- **currentPbr** (number) - Optional - Current Price-to-Book ratio
- **currentYield** (number) - Optional - Current dividend yield percentage
- **targetPer** (number) - Optional - Target P/E ratio for buy price calculation
- **targetPbr** (number) - Optional - Target P/B ratio for buy price calculation
- **targetYield** (number) - Optional - Target dividend yield for buy price calculation
- **lang** (string) - Optional - Force language ('en' or 'ja')
### Request Example
GET /?stockPrice=1000&targetPer=15
### Response
#### Success Response (200)
- **HTML** (text/html) - The rendered calculator page with pre-populated values.
```
--------------------------------
### Perform Unit and Integration Testing
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
Deno test suite examples covering fundamental calculations, bottleneck logic, and HTTP route integration. These tests ensure the accuracy of financial derivations and API response headers.
```typescript
import { assertEquals } from "@std/assert";
import { calculateFundamentals, calculateTargetPrices } from "./utils/pricing.ts";
Deno.test("calculateFundamentals correctly derives EPS, BPS, Dividend", () => {
const state = { price: 1000, per: 20, pbr: 2, yield: 3 };
const fundamentals = calculateFundamentals(state);
assertEquals(fundamentals.eps, 50);
assertEquals(fundamentals.bps, 500);
assertEquals(fundamentals.dividend, 30);
});
Deno.test("calculateTargetPrices identifies distinct bottleneck", () => {
const fundamentals = { eps: 100, bps: 1000, dividend: 20 };
const targets = { per: 10, pbr: 1.2, yield: 1 };
const prices = calculateTargetPrices(fundamentals, targets);
assertEquals(prices.minPrice, 1000);
assertEquals(prices.bottleneck, "per");
});
Deno.test("GET / defaults to English", async () => {
const req = new Request("http://localhost:8000/");
const res = await app.request(req);
assertEquals(res.status, 200);
assertEquals(res.headers.get("vary"), "Cookie, Accept-Language");
});
```
--------------------------------
### Guide Endpoints
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
Endpoints for accessing the English and Japanese guides. The application also supports auto-redirect based on the browser's Accept-Language header.
```APIDOC
## GET /guide/
### Description
Retrieves the guide in English. If the Accept-Language header indicates Japanese, it may redirect to the Japanese version.
### Method
GET
### Endpoint
/guide/
### Request Example
```bash
curl -X GET "http://localhost:8000/guide/"
```
### Response Example
```
(HTML content of the English guide)
```
## GET /ja/guide/
### Description
Retrieves the guide in Japanese.
### Method
GET
### Endpoint
/ja/guide/
### Request Example
```bash
curl -X GET "http://localhost:8000/ja/guide/"
```
### Response Example
```
(HTML content of the Japanese guide)
```
## Auto-redirect based on browser language
### Description
Requests the guide endpoint with an Accept-Language header to trigger language-based redirection.
### Method
GET
### Endpoint
/guide/
### Request Example
```bash
curl -X GET "http://localhost:8000/guide/" \
-H "Accept-Language: ja-JP,ja;q=0.9,en;q=0.8"
```
### Response Example
```
302 Redirect to /ja/guide/
```
```
--------------------------------
### Access Calculator Page (Bash)
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
Demonstrates how to access the main calculator interface using curl. It shows basic requests, pre-populating fields via query parameters, and how language detection and persistence work via headers and cookies. The examples illustrate redirects for different languages and setting user preferences.
```bash
# Basic request - returns English calculator
curl -X GET "http://localhost:8000/"
# Pre-populate calculator with stock data via query params
curl -X GET "http://localhost:8000/?stockPrice=1000¤tPer=20¤tPbr=2¤tYield=3&targetPer=15&targetPbr=1.5&targetYield=4"
# Japanese browser gets redirected to /ja/
curl -X GET "http://localhost:8000/" \
-H "Accept-Language: ja,en-US;q=0.9,en;q=0.8"
# Response: 302 Redirect to http://localhost:8000/ja/
# Direct Japanese version
curl -X GET "http://localhost:8000/ja/"
# Persist language preference (redirects and sets cookie)
curl -X GET "http://localhost:8000/?lang=ja"
# Response: 301 Redirect to /ja/ with Set-Cookie: preferred_lang=ja
# Request with existing language preference cookie
curl -X GET "http://localhost:8000/" \
-H "Cookie: preferred_lang=ja"
# Response: 302 Redirect to /ja/
```
--------------------------------
### Rendering Layout and Calculator View Components
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
Shows how to use a base HTML layout component with SEO metadata and structured data. It includes examples for rendering the main calculator page and article pages, specifying page types and passing relevant data.
```typescript
import { Layout } from "./views/Layout.tsx";
import { Calculator } from "./views/Calculator.tsx";
// Render calculator page with full layout
app.get("/", (c) => {
const t = i18next.getFixedT("en");
return c.html(
);
});
// Render article pages with Article structured data
app.get("/guide/", (c) => {
const t = i18next.getFixedT("en");
const articleJson = {
"@context": "https://schema.org",
"@type": "Article",
headline: t("guideTitle"),
description: t("guideDescription"),
inLanguage: "en",
url: "https://stock-back-calc.syaryn.com/guide/",
};
return c.html(
);
});
```
--------------------------------
### Accessing About Page via HTTP GET Requests
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
Shows how to retrieve information about the calculator's purpose and features from both the English and Japanese 'About' pages using curl.
```bash
# English about page
curl -X GET "http://localhost:8000/about/"
# Japanese about page
curl -X GET "http://localhost:8000/ja/about/"
```
--------------------------------
### Layout Component Rendering
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
Examples of rendering the base HTML layout component, including calculator pages and article pages with structured data.
```APIDOC
## Layout Component Rendering Examples
### Description
Demonstrates how to use the `Layout` component to render different types of pages, such as the main calculator interface and article pages, with appropriate SEO metadata and structured data.
### Method
N/A (Code examples)
### Endpoint
N/A
### Parameters
N/A
### Request Example
```typescript
import { Layout } from "./views/Layout.tsx";
import { Calculator } from "./views/Calculator.tsx";
// Render calculator page with full layout
app.get("/", (c) => {
const t = i18next.getFixedT("en");
return c.html(
);
});
// Render article pages with Article structured data
app.get("/guide/", (c) => {
const t = i18next.getFixedT("en");
const articleJson = {
"@context": "https://schema.org",
"@type": "Article",
headline: t("guideTitle"),
description: t("guideDescription"),
inLanguage: "en",
url: "https://stock-back-calc.syaryn.com/guide/",
};
return c.html(
);
});
```
### Response
#### Success Response (200)
N/A (Code rendering examples)
#### Response Example
N/A
```
--------------------------------
### Run Test Suite (Bash)
Source: https://github.com/syaryn/stock_back_calc/blob/main/README.md
Command to execute the test suite, including integration and unit tests, for the Stock Target Price Calculator. Requires Deno or Mise to be installed.
```bash
mise run check
# or
deno task check
```
--------------------------------
### i18next Language Configuration and Translation
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
Illustrates how to configure i18next for internationalization, setting default and available locales. It shows how to get translation functions for specific languages and use them to translate strings and access nested translation objects like FAQ items.
```typescript
import i18next, { Language, i18nConfig } from "./utils/i18n.ts";
// Available configuration
console.log(i18nConfig);
// { defaultLocale: "en", locales: ["en", "ja"] }
// Get translation function for specific language
const tEn = i18next.getFixedT("en");
const tJa = i18next.getFixedT("ja");
// Use translations
console.log(tEn("stockPrice")); // "Stock Price"
console.log(tJa("stockPrice")); // "株価"
console.log(tEn("currentPer")); // "Current PER"
console.log(tJa("currentPer")); // "現在 PER"
console.log(tEn("bottleneck")); // "Bottleneck Indicator"
console.log(tJa("bottleneck")); // "ボトルネック指標"
// Access FAQ items
const faqItems = tEn("faq", { returnObjects: true });
// Returns array of { q: string, a: string } objects
```
--------------------------------
### Client-side Calculation and UI Reflection with Alpine.js
Source: https://github.com/syaryn/stock_back_calc/blob/main/docs/gist/article_2_implementation_en.md
This example shows how Alpine.js handles client-side calculations and UI updates. It uses `x-data` to define state, `x-model` to bind input values, and `x-text` to display computed results. This approach delegates calculations that don't require server interaction to the browser, simplifying the overall architecture.
```html
Target Price: JPY
```
--------------------------------
### Accessing SEO Endpoints (robots.txt and sitemap.xml)
Source: https://context7.com/syaryn/stock_back_calc/llms.txt
Demonstrates how to fetch the robots.txt file, which controls search engine crawling, and the sitemap.xml file, which lists all localized URLs for better SEO.
```bash
# Robots.txt
curl -X GET "http://localhost:8000/robots.txt"
# Response:
# User-agent: *
# Allow: /
# Sitemap: https://stock-back-calc.syaryn.com/sitemap.xml
# Sitemap with all localized URLs
curl -X GET "http://localhost:8000/sitemap.xml"
# Returns XML sitemap with hreflang alternates for all pages
```
--------------------------------
### Define Deno Hono Web Stack Skill Configuration
Source: https://github.com/syaryn/stock_back_calc/blob/main/docs/gist/article_1_skill_creation_en.md
A Markdown-based definition file (SKILL.md) that provides the AI agent with metadata, usage instructions, and quick-start procedures for the Deno/Hono web stack.
```markdown
---
name: deno-hono-web-stack
description: Expert assistance for developing web applications using Deno, Hono, Htmx, PicoCSS, Alpine.js, and Lefthook.
---
# Deno Hono Web Stack Skill
## When to use this skill
- Setting up a new web project with the Deno/Hono stack.
- Implementing server-side rendering (SSR) with Hono's JSX middleware.
## Quick Start (New Project)
To create a new project using the bundled template:
1. Copy the contents of `resources/template/` to the project root.
2. Run `mise install` to set up the environment.
```
--------------------------------
### Semantic HTML Structure with Pico.css
Source: https://github.com/syaryn/stock_back_calc/blob/main/docs/gist/article_2_implementation_en.md
This snippet illustrates the use of Pico.css for UI design by leveraging semantic HTML tags. By simply using elements like ``, ``, and `