# dilshadk9/kodo-assignment architecture

> Architecture diagram of the GitHub repository dilshadk9/kodo-assignment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dilshadk9/kodo-assignment
- Repository: https://github.com/dilshadk9/kodo-assignment

## Overview

This is a Node.js posts browser and REST API. Users can browse or search posts, with the web view adding pagination and sorting; API clients can request all posts or search results. Search results can be served from Redis, with cache misses fetched through the search API and then cached. The shown source supports the routing and service links below; templates and mock data are represented from the tree, while Redis is documented in the README.

Main entry points: [`app.js`](https://github.com/dilshadk9/kodo-assignment/blob/main/app.js) (Express application), [`services/posts-service.js`](https://github.com/dilshadk9/kodo-assignment/blob/main/services/posts-service.js) (Post and search service), [`routes/posts.js`](https://github.com/dilshadk9/kodo-assignment/blob/main/routes/posts.js) (Posts pages), [`routes/postApi.js`](https://github.com/dilshadk9/kodo-assignment/blob/main/routes/postApi.js) (Posts API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_application["Express application<br/>[app.js]"]
  node_home["Home redirect<br/>[index.js]"]
  node_web_posts["Posts pages<br/>[posts.js]"]
  node_posts_view["Posts template<br/>[posts.ejs]"]
end

subgraph group_api["REST API"]
  node_post_api["Posts API<br/>[postApi.js]"]
end

subgraph group_data["Posts and cache"]
  node_post_service["Post and search service<br/>[posts-service.js]"]
  node_mock_data["Mock posts<br/>[mock_data.json]"]
  node_redis[("Redis cache")]
end

node_user(("Browser user"))
node_client(("API client"))

node_user -->|"requests pages"| node_application
node_client -->|"requests API"| node_application
node_application -->|"mounts at /"| node_home
node_application -->|"mounts at /posts"| node_web_posts
node_application -->|"mounts at /api/posts"| node_post_api
node_home -->|"redirects to"| node_web_posts
node_web_posts -->|"requests posts"| node_post_service
node_web_posts -->|"renders"| node_posts_view
node_post_api -->|"requests posts"| node_post_service
node_post_service -->|"reads posts"| node_mock_data
node_post_service -->|"reads and writes cache"| node_redis
node_post_service -->|"fetches search results"| node_post_api

click node_application "https://github.com/dilshadk9/kodo-assignment/blob/main/app.js"
click node_home "https://github.com/dilshadk9/kodo-assignment/blob/main/routes/index.js"
click node_web_posts "https://github.com/dilshadk9/kodo-assignment/blob/main/routes/posts.js"
click node_posts_view "https://github.com/dilshadk9/kodo-assignment/blob/main/views/posts.ejs"
click node_post_api "https://github.com/dilshadk9/kodo-assignment/blob/main/routes/postApi.js"
click node_post_service "https://github.com/dilshadk9/kodo-assignment/blob/main/services/posts-service.js"
click node_mock_data "https://github.com/dilshadk9/kodo-assignment/blob/main/mock_data.json"

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_application,node_home,node_web_posts,node_posts_view,node_user,node_client toneBlue
class node_post_api toneAmber
class node_post_service,node_mock_data,node_redis toneMint
```

## Components

### Web experience

- [Express application](https://github.com/dilshadk9/kodo-assignment/blob/main/app.js): `app.js`
- [Home redirect](https://github.com/dilshadk9/kodo-assignment/blob/main/routes/index.js): `routes/index.js`
- [Posts pages](https://github.com/dilshadk9/kodo-assignment/blob/main/routes/posts.js): `routes/posts.js`
- [Posts template](https://github.com/dilshadk9/kodo-assignment/blob/main/views/posts.ejs): `views/posts.ejs`

### REST API

- [Posts API](https://github.com/dilshadk9/kodo-assignment/blob/main/routes/postApi.js): `routes/postApi.js`

### Posts and cache

- [Post and search service](https://github.com/dilshadk9/kodo-assignment/blob/main/services/posts-service.js): `services/posts-service.js`
- [Mock posts](https://github.com/dilshadk9/kodo-assignment/blob/main/mock_data.json): `mock_data.json`
- **Redis cache**

### Other components

- **Browser user**
- **API client**

## Connections

- Browser user → Express application: requests pages (evidence: `README.md`)
- API client → Express application: requests API (evidence: `README.md`)
- Express application → Home redirect: mounts at / (evidence: `app.js`)
- Express application → Posts pages: mounts at /posts (evidence: `app.js`)
- Express application → Posts API: mounts at /api/posts (evidence: `app.js`)
- Home redirect → Posts pages: redirects to (evidence: `routes/index.js`)
- Posts pages → Post and search service: requests posts (evidence: `routes/posts.js`)
- Posts pages → Posts template: renders (evidence: `routes/posts.js`)
- Posts API → Post and search service: requests posts (evidence: `routes/postApi.js`)
- Post and search service → Mock posts: reads posts (evidence: `services/posts-service.js`)
- Post and search service → Redis cache: reads and writes cache (evidence: `services/posts-service.js`)
- Post and search service → Posts API: fetches search results (evidence: `services/posts-service.js`)
