# ahmed-init/yen-karuvigal architecture

> Architecture diagram of the GitHub repository ahmed-init/yen-karuvigal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmed-init/yen-karuvigal
- Repository: https://github.com/ahmed-init/yen-karuvigal

## Overview

#### Purpose and Runtime
Tool Registry is a lightweight, unauthenticated CRUD application for recording technologies/tools, their category, purpose, learning status, and difficulty. It runs on Node.js with TypeScript and Express, persists records in MySQL through `mysql2`, and uses environment variables for database configuration. The deployed service is hosted on Render.

Core runtime entry point: `src/server.ts`. TypeScript database integration: `src/db/database.ts`.

#### Application Entry Points
The Express server accepts JSON API requests under `/api` and serves the browser client as static assets. Public consumers can call the REST API directly or use the included HTML/JavaScript frontend.

- Server/API entry: `src/server.ts`
- Database connection boundary: `src/db/database.ts`
- Browser entry: `public/index.html`
- Browser behavior/API client: `public/app.js`

#### REST CRUD Layer
`src/server.ts` owns the HTTP surface and CRUD control flow for the tool registry:

- `POST /api/tools`: create a tool.
- `GET /api/gettools`: list tools.
- `GET /api/gettool/:id`: fetch one tool.
- `PUT /api/modifytool/:id`: update a tool.
- `DELETE /api/deletetool/:id`: delete a tool.

Handlers read route parameters and request bodies, issue asynchronous database operations, then return JSON and HTTP status responses. There is no separate controller, service, or domain-model layer; routing and application logic are colocated in the server module.

#### Persistence Boundary
MySQL is the system of record. `src/db/database.ts` establishes and exports the database connection/pool used by request handlers. The API layer interacts with MySQL through parameterized SQL queries, isolating persistence access to this module boundary rather than embedding connection setup in every route.

- Connection setup/export: `src/db/database.ts`
- Query callers and CRUD behavior: `src/server.ts`
- Environment-variable template: `.env.example`

The persisted tool shape includes identity, descriptive fields (`name`, `category`, `purpose`), progress fields (`status`, `difficulty`), and creation/update timestamps.

#### Client-to-Database Flow
The primary flow is:

1. A user loads `public/index.html`.
2. `public/app.js` renders or collects tool data and calls API endpoints.
3. Express in `src/server.ts` parses the request and selects the CRUD handler.
4. The handler uses the MySQL connection exported by `src/db/database.ts`.
5. MySQL results are converted to JSON responses consumed by the client.

Direct API consumers such as Postman follow the same server-to-database path without the static frontend.

#### Frontend Boundary
The frontend is a plain static client, not a separate framework application or server-rendered UI. Its responsibility is presentation and REST calls; authoritative state remains in MySQL.

- Document/UI shell: `public/index.html`
- API interaction and client-side behavior: `public/app.js`
- Styling: `public/styles.css`

#### Operational Characteristics
The repository has a single deployable Node process. It depends on a reachable MySQL instance and runtime environment configuration; no authentication or tenant/user boundary exists, so all callers share one common registry. Package/runtime definitions are in `package.json`, with TypeScript compilation behavior in `tsconfig.json`.

Main entry points: [`src/server.ts`](https://github.com/ahmed-init/yen-karuvigal/blob/main/src/server.ts) (Express server), [`public/index.html`](https://github.com/ahmed-init/yen-karuvigal/blob/main/public/index.html) (UI document), [`src/db/database.ts`](https://github.com/ahmed-init/yen-karuvigal/blob/main/src/db/database.ts) (Database connection), [`public/app.js`](https://github.com/ahmed-init/yen-karuvigal/blob/main/public/app.js) (API client behavior)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_browser(("Browser user<br/>consumer"))
  node_html["UI document<br/>static HTML<br/>[index.html]"]
  node_app["API client behavior<br/>browser JavaScript<br/>[app.js]"]
  node_styles["UI styles<br/>CSS<br/>[styles.css]"]
end

subgraph group_service["Node service"]
  node_server["Express server<br/>Node.js entry point<br/>[server.ts]"]
  node_crud["CRUD route handlers<br/>Express routes<br/>[server.ts]"]
end

subgraph group_persistence["Persistence"]
  node_db_module["Database connection<br/>mysql2 boundary<br/>[database.ts]"]
  node_mysql[("Tool registry<br/>MySQL system of record")]
  node_env["Database environment<br/>environment variables<br/>[.env.example]"]
end

node_api_consumer(("Direct API consumer<br/>REST consumer"))
node_render{{"Render deployment<br/>hosting platform"}}

node_browser -->|"loads"| node_html
node_html -->|"loads"| node_app
node_html -->|"loads"| node_styles
node_app -->|"REST requests"| node_server
node_api_consumer -->|"REST requests"| node_server
node_server -->|"/api tools CRUD"| node_crud
node_server -->|"serves static assets"| node_html
node_crud -->|"parameterized queries"| node_db_module
node_db_module -->|"mysql2 access"| node_mysql
node_env -.->|"database configuration"| node_db_module
node_render -->|"runs"| node_server

click node_html "https://github.com/ahmed-init/yen-karuvigal/blob/main/public/index.html"
click node_app "https://github.com/ahmed-init/yen-karuvigal/blob/main/public/app.js"
click node_styles "https://github.com/ahmed-init/yen-karuvigal/blob/main/public/styles.css"
click node_server "https://github.com/ahmed-init/yen-karuvigal/blob/main/src/server.ts"
click node_crud "https://github.com/ahmed-init/yen-karuvigal/blob/main/src/server.ts"
click node_db_module "https://github.com/ahmed-init/yen-karuvigal/blob/main/src/db/database.ts"
click node_env "https://github.com/ahmed-init/yen-karuvigal/blob/main/.env.example"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_html,node_app,node_styles toneBlue
class node_server,node_crud toneAmber
class node_db_module,node_mysql,node_env toneMint
class node_api_consumer,node_render toneNeutral
```

## Components

### Browser client

- **Browser user**: consumer
- [UI document](https://github.com/ahmed-init/yen-karuvigal/blob/main/public/index.html): static HTML · `public/index.html`
- [API client behavior](https://github.com/ahmed-init/yen-karuvigal/blob/main/public/app.js): browser JavaScript · Renders UI and issues REST CRUD requests. · `public/app.js`
- [UI styles](https://github.com/ahmed-init/yen-karuvigal/blob/main/public/styles.css): CSS · `public/styles.css`

### Node service

- [Express server](https://github.com/ahmed-init/yen-karuvigal/blob/main/src/server.ts): Node.js entry point · Serves static assets and mounts the JSON API under /api. · `src/server.ts`
- [CRUD route handlers](https://github.com/ahmed-init/yen-karuvigal/blob/main/src/server.ts): Express routes · Colocated create, list, read, update, and delete logic. · `src/server.ts`

### Persistence

- [Database connection](https://github.com/ahmed-init/yen-karuvigal/blob/main/src/db/database.ts): mysql2 boundary · Establishes and exports the connection or pool used by handlers. · `src/db/database.ts`
- **Tool registry**: MySQL system of record · Stores tool details, learning fields, and timestamps.
- [Database environment](https://github.com/ahmed-init/yen-karuvigal/blob/main/.env.example): environment variables · Supplies database configuration at runtime. · `.env.example`

### Other components

- **Direct API consumer**: REST consumer · Clients such as Postman use the same public API.
- **Render deployment**: hosting platform · Hosts the single Node process.

## Connections

- Browser user → UI document: loads
- UI document → API client behavior: loads
- UI document → UI styles: loads
- API client behavior → Express server: REST requests
- Direct API consumer → Express server: REST requests
- Express server → CRUD route handlers: /api tools CRUD
- Express server → UI document: serves static assets
- CRUD route handlers → Database connection: parameterized queries
- Database connection → Tool registry: mysql2 access
- Database environment → Database connection: database configuration
- Render deployment → Express server: runs
