# ch1burek/laba-back-end architecture

> Architecture diagram of the GitHub repository ch1burek/laba-back-end, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ch1burek/laba-back-end
- Repository: https://github.com/ch1burek/laba-back-end

## Overview

This is a Next.js country-information website with a local SQLite-backed JSON API. The main user workflow loads a country dropdown, fetches selected-country details, and renders a country card. A separate optional city-details endpoint is documented. Relationships below follow the shown route calls, client fetches, and database helper usage; no unsampled implementation is assumed.

Main entry points: [`lib/countries.ts`](https://github.com/ch1burek/laba-back-end/blob/master/lib/countries.ts) (Country queries), [`components/CountryExplorer.tsx`](https://github.com/ch1burek/laba-back-end/blob/master/components/CountryExplorer.tsx) (Country explorer), [`lib/db.ts`](https://github.com/ch1burek/laba-back-end/blob/master/lib/db.ts) (Database setup), [`app/page.tsx`](https://github.com/ch1burek/laba-back-end/blob/master/app/page.tsx) (Home page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Country Explorer"]
  node_home["Home page<br/>[page.tsx]"]
  node_explorer["Country explorer"]
end

subgraph group_api["JSON API"]
  node_list_route["Country list route<br/>[route.ts]"]
  node_country_route["Country details route<br/>[route.ts]"]
  node_city_route["City details route<br/>[route.ts]"]
end

subgraph group_data["Country Data"]
  node_queries["Country queries<br/>[countries.ts]"]
  node_db_helper["Database setup<br/>[db.ts]"]
  node_seed["Initial records<br/>[seed-data.ts]"]
  node_sqlite[("SQLite database")]
  node_types["Data contracts<br/>[types.ts]"]
end

node_visitor(("Browser user"))

node_visitor -->|"opens"| node_home
node_home -->|"renders"| node_explorer
node_explorer -->|"fetches list"| node_list_route
node_explorer -->|"fetches details"| node_country_route
node_visitor -.->|"requests city"| node_city_route
node_list_route -->|"calls list query"| node_queries
node_country_route -->|"calls detail query"| node_queries
node_city_route -->|"calls city query"| node_queries
node_queries -->|"gets connection"| node_db_helper
node_db_helper -->|"seeds tables"| node_seed
node_db_helper -->|"creates and caches"| node_sqlite
node_queries -->|"queries rows"| node_sqlite
node_queries -->|"maps typed rows"| node_types
node_explorer -->|"renders country card"| node_visitor

click node_home "https://github.com/ch1burek/laba-back-end/blob/master/app/page.tsx"
click node_explorer "https://github.com/ch1burek/laba-back-end/blob/master/components/CountryExplorer.tsx"
click node_list_route "https://github.com/ch1burek/laba-back-end/blob/master/app/mycountries/v1.1/getcountrieslist/route.ts"
click node_country_route "https://github.com/ch1burek/laba-back-end/blob/master/app/mycountries/v1.1/getcountry/%5Bcountryname%5D/route.ts"
click node_city_route "https://github.com/ch1burek/laba-back-end/blob/master/app/mycountries/v1.1/getcity/%5Bcityname%5D/route.ts"
click node_queries "https://github.com/ch1burek/laba-back-end/blob/master/lib/countries.ts"
click node_db_helper "https://github.com/ch1burek/laba-back-end/blob/master/lib/db.ts"
click node_seed "https://github.com/ch1burek/laba-back-end/blob/master/lib/seed-data.ts"
click node_types "https://github.com/ch1burek/laba-back-end/blob/master/lib/types.ts"

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_home,node_explorer,node_visitor toneBlue
class node_list_route,node_country_route,node_city_route toneAmber
class node_queries,node_db_helper,node_seed,node_sqlite,node_types toneMint
```

## Components

### Country Explorer

- [Home page](https://github.com/ch1burek/laba-back-end/blob/master/app/page.tsx): `app/page.tsx`
- [Country explorer](https://github.com/ch1burek/laba-back-end/blob/master/components/CountryExplorer.tsx): `components/CountryExplorer.tsx`

### JSON API

- [Country list route](https://github.com/ch1burek/laba-back-end/blob/master/app/mycountries/v1.1/getcountrieslist/route.ts): `app/mycountries/v1.1/getcountrieslist/route.ts`
- [Country details route](https://github.com/ch1burek/laba-back-end/blob/master/app/mycountries/v1.1/getcountry/%5Bcountryname%5D/route.ts): `app/mycountries/v1.1/getcountry/[countryname]/route.ts`
- [City details route](https://github.com/ch1burek/laba-back-end/blob/master/app/mycountries/v1.1/getcity/%5Bcityname%5D/route.ts): `app/mycountries/v1.1/getcity/[cityname]/route.ts`

### Country Data

- [Country queries](https://github.com/ch1burek/laba-back-end/blob/master/lib/countries.ts): `lib/countries.ts`
- [Database setup](https://github.com/ch1burek/laba-back-end/blob/master/lib/db.ts): `lib/db.ts`
- [Initial records](https://github.com/ch1burek/laba-back-end/blob/master/lib/seed-data.ts): `lib/seed-data.ts`
- **SQLite database**
- [Data contracts](https://github.com/ch1burek/laba-back-end/blob/master/lib/types.ts): `lib/types.ts`

### Other components

- **Browser user**

## Connections

- Browser user → Home page: opens (evidence: `README.md`)
- Home page → Country explorer: renders (evidence: `app/page.tsx`)
- Country explorer → Country list route: fetches list (evidence: `README.md`)
- Country explorer → Country details route: fetches details (evidence: `README.md`)
- Browser user → City details route: requests city (evidence: `README.md`)
- Country list route → Country queries: calls list query (evidence: `app/mycountries/v1.1/getcountrieslist/route.ts`)
- Country details route → Country queries: calls detail query (evidence: `app/mycountries/v1.1/getcountry/[countryname]/route.ts`)
- City details route → Country queries: calls city query (evidence: `app/mycountries/v1.1/getcity/[cityname]/route.ts`)
- Country queries → Database setup: gets connection (evidence: `lib/countries.ts`)
- Database setup → Initial records: seeds tables (evidence: `lib/db.ts`)
- Database setup → SQLite database: creates and caches (evidence: `README.md`)
- Country queries → SQLite database: queries rows (evidence: `README.md`)
- Country queries → Data contracts: maps typed rows (evidence: `lib/countries.ts`)
- Country explorer → Browser user: renders country card (evidence: `README.md`)
