# prabanta-dev/janas architecture

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

- Interactive diagram: https://gitdiagram.com/prabanta-dev/janas
- Repository: https://github.com/prabanta-dev/janas

## Overview

Janas is a C toolkit centered on Janas-LLM: users can obtain a model, run it in a terminal chat, expose it through an OpenAI-compatible HTTP server, or connect it to MCP clients and tool services. The graph also preserves the model-loading and GPU execution layer and the documented model-download workflow. Edges reflect README statements and the supplied source index or excerpts; unsampled implementations are represented only where the tree and documentation support the subsystem.

Main entry points: [`src/common/mcp_server.c`](https://github.com/prabanta-dev/janas/blob/main/src/common/mcp_server.c) (MCP stdio server), [`src/server/main.c`](https://github.com/prabanta-dev/janas/blob/main/src/server/main.c) (HTTP API server), [`src/get/main.c`](https://github.com/prabanta-dev/janas/blob/main/src/get/main.c) (Model downloader), [`include/janas/llm.h`](https://github.com/prabanta-dev/janas/blob/main/include/janas/llm.h) (Public LLM API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_chat["Terminal chat<br/>[main.c]"]
  node_server["HTTP API server<br/>[main.c]"]
  node_http["HTTP routing<br/>[http.c]"]
  node_engine["Request engine<br/>[engine.c]"]
  node_store[("Conversation store<br/>[store.c]")]
end

subgraph group_runtime["LLM runtime"]
  node_publicapi["Public LLM API<br/>[llm.h]"]
  node_model_load["Model loading<br/>[model_load.c]"]
  node_generation["Token generation<br/>[generate.c]"]
  node_gpu["GPU execution<br/>[gpu.c]"]
end

subgraph group_mcp["MCP ecosystem"]
  node_mcp_client["MCP client<br/>[mcp_client.c]"]
  node_mcp_chat["Chat tool flow<br/>[mcp_chat.c]"]
  node_mcp_app["Model MCP server<br/>[main.c]"]
  node_mcp_protocol["MCP stdio server<br/>[mcp_server.c]"]
end

subgraph group_services["MCP tool services"]
  node_flight["Flight tools<br/>[tools.c]"]
  node_maps["Map tools<br/>[tools.c]"]
  node_weather["Weather tools<br/>[tools.c]"]
  node_git["Git tools<br/>[tools.c]"]
  node_github["GitHub tools<br/>[tools.c]"]
  node_prices["Price tools<br/>[tools.c]"]
  node_quakes["Earthquake tools<br/>[tools.c]"]
  node_system["System tools<br/>[tools.c]"]
  node_wiki["Wiki tools<br/>[tools.c]"]
end

subgraph group_models["Model acquisition"]
  node_get["Model downloader<br/>[main.c]"]
  node_catalog["Model catalog<br/>[catalog.c]"]
end

node_user(("User"))
node_mcp_user(("MCP client app"))
node_hf(("Hugging Face"))

node_user -->|"chats with"| node_chat
node_chat -->|"calls"| node_publicapi
node_user -->|"sends requests"| node_server
node_server -->|"starts"| node_http
node_http -.->|"dispatches"| node_engine
node_engine -->|"generates with"| node_publicapi
node_server -->|"configures"| node_store
node_publicapi -->|"opens models"| node_model_load
node_model_load -->|"uses"| node_gpu
node_user -->|"requests model"| node_get
node_get -->|"selects from"| node_catalog
node_get -->|"downloads from"| node_hf
node_mcp_user -->|"starts"| node_mcp_app
node_mcp_app -->|"serves over stdio"| node_mcp_protocol
node_mcp_user -.->|"connects through"| node_mcp_client
node_mcp_chat -->|"uses"| node_mcp_client
node_flight -->|"registers tools"| node_mcp_protocol
node_maps -->|"registers tools"| node_mcp_protocol
node_weather -->|"registers tools"| node_mcp_protocol
node_git -->|"registers tools"| node_mcp_protocol
node_github -->|"registers tools"| node_mcp_protocol
node_prices -->|"registers tools"| node_mcp_protocol
node_quakes -->|"registers tools"| node_mcp_protocol
node_system -->|"registers tools"| node_mcp_protocol
node_wiki -->|"registers tools"| node_mcp_protocol

click node_chat "https://github.com/prabanta-dev/janas/blob/main/src/chat/main.c"
click node_server "https://github.com/prabanta-dev/janas/blob/main/src/server/main.c"
click node_http "https://github.com/prabanta-dev/janas/blob/main/src/server/http.c"
click node_engine "https://github.com/prabanta-dev/janas/blob/main/src/server/engine.c"
click node_store "https://github.com/prabanta-dev/janas/blob/main/src/server/store.c"
click node_publicapi "https://github.com/prabanta-dev/janas/blob/main/include/janas/llm.h"
click node_model_load "https://github.com/prabanta-dev/janas/blob/main/src/llm/model_load.c"
click node_generation "https://github.com/prabanta-dev/janas/blob/main/src/llm/generate.c"
click node_gpu "https://github.com/prabanta-dev/janas/blob/main/src/llm/gpu.c"
click node_mcp_client "https://github.com/prabanta-dev/janas/blob/main/src/common/mcp_client.c"
click node_mcp_chat "https://github.com/prabanta-dev/janas/blob/main/src/chat/mcp_chat.c"
click node_mcp_app "https://github.com/prabanta-dev/janas/blob/main/src/mcp/main.c"
click node_mcp_protocol "https://github.com/prabanta-dev/janas/blob/main/src/common/mcp_server.c"
click node_flight "https://github.com/prabanta-dev/janas/blob/main/src/services/flights/tools.c"
click node_maps "https://github.com/prabanta-dev/janas/blob/main/src/services/maps/tools.c"
click node_weather "https://github.com/prabanta-dev/janas/blob/main/src/services/weather/tools.c"
click node_git "https://github.com/prabanta-dev/janas/blob/main/src/services/git/tools.c"
click node_github "https://github.com/prabanta-dev/janas/blob/main/src/services/github/tools.c"
click node_prices "https://github.com/prabanta-dev/janas/blob/main/src/services/prices/tools.c"
click node_quakes "https://github.com/prabanta-dev/janas/blob/main/src/services/quakes/tools.c"
click node_system "https://github.com/prabanta-dev/janas/blob/main/src/services/system/tools.c"
click node_wiki "https://github.com/prabanta-dev/janas/blob/main/src/services/wiki/tools.c"
click node_get "https://github.com/prabanta-dev/janas/blob/main/src/get/main.c"
click node_catalog "https://github.com/prabanta-dev/janas/blob/main/src/common/catalog.c"

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_chat,node_server,node_http,node_engine,node_store,node_user,node_mcp_user toneBlue
class node_publicapi,node_model_load,node_generation,node_gpu toneAmber
class node_mcp_client,node_mcp_chat,node_mcp_app,node_mcp_protocol toneMint
class node_flight,node_maps,node_weather,node_git,node_github,node_prices,node_quakes,node_system,node_wiki toneRose
class node_get,node_catalog,node_hf toneIndigo
```

## Components

### User interfaces

- [Terminal chat](https://github.com/prabanta-dev/janas/blob/main/src/chat/main.c): `src/chat/main.c`
- [HTTP API server](https://github.com/prabanta-dev/janas/blob/main/src/server/main.c): `src/server/main.c`
- [HTTP routing](https://github.com/prabanta-dev/janas/blob/main/src/server/http.c): `src/server/http.c`
- [Request engine](https://github.com/prabanta-dev/janas/blob/main/src/server/engine.c): `src/server/engine.c`
- [Conversation store](https://github.com/prabanta-dev/janas/blob/main/src/server/store.c): `src/server/store.c`

### LLM runtime

- [Public LLM API](https://github.com/prabanta-dev/janas/blob/main/include/janas/llm.h): `include/janas/llm.h`
- [Model loading](https://github.com/prabanta-dev/janas/blob/main/src/llm/model_load.c): `src/llm/model_load.c`
- [Token generation](https://github.com/prabanta-dev/janas/blob/main/src/llm/generate.c): `src/llm/generate.c`
- [GPU execution](https://github.com/prabanta-dev/janas/blob/main/src/llm/gpu.c): `src/llm/gpu.c`

### MCP ecosystem

- [MCP client](https://github.com/prabanta-dev/janas/blob/main/src/common/mcp_client.c): `src/common/mcp_client.c`
- [Chat tool flow](https://github.com/prabanta-dev/janas/blob/main/src/chat/mcp_chat.c): `src/chat/mcp_chat.c`
- [Model MCP server](https://github.com/prabanta-dev/janas/blob/main/src/mcp/main.c): `src/mcp/main.c`
- [MCP stdio server](https://github.com/prabanta-dev/janas/blob/main/src/common/mcp_server.c): `src/common/mcp_server.c`

### MCP tool services

- [Flight tools](https://github.com/prabanta-dev/janas/blob/main/src/services/flights/tools.c): `src/services/flights/tools.c`
- [Map tools](https://github.com/prabanta-dev/janas/blob/main/src/services/maps/tools.c): `src/services/maps/tools.c`
- [Weather tools](https://github.com/prabanta-dev/janas/blob/main/src/services/weather/tools.c): `src/services/weather/tools.c`
- [Git tools](https://github.com/prabanta-dev/janas/blob/main/src/services/git/tools.c): `src/services/git/tools.c`
- [GitHub tools](https://github.com/prabanta-dev/janas/blob/main/src/services/github/tools.c): `src/services/github/tools.c`
- [Price tools](https://github.com/prabanta-dev/janas/blob/main/src/services/prices/tools.c): `src/services/prices/tools.c`
- [Earthquake tools](https://github.com/prabanta-dev/janas/blob/main/src/services/quakes/tools.c): `src/services/quakes/tools.c`
- [System tools](https://github.com/prabanta-dev/janas/blob/main/src/services/system/tools.c): `src/services/system/tools.c`
- [Wiki tools](https://github.com/prabanta-dev/janas/blob/main/src/services/wiki/tools.c): `src/services/wiki/tools.c`

### Model acquisition

- [Model downloader](https://github.com/prabanta-dev/janas/blob/main/src/get/main.c): `src/get/main.c`
- [Model catalog](https://github.com/prabanta-dev/janas/blob/main/src/common/catalog.c): `src/common/catalog.c`

### Other components

- **User**
- **MCP client app**
- **Hugging Face**

## Connections

- User → Terminal chat: chats with
- Terminal chat → Public LLM API: calls (evidence: `src/chat/main.c`)
- User → HTTP API server: sends requests
- HTTP API server → HTTP routing: starts (evidence: `src/server/main.c`)
- HTTP routing → Request engine: dispatches
- Request engine → Public LLM API: generates with (evidence: `src/server/engine.c`)
- HTTP API server → Conversation store: configures
- Public LLM API → Model loading: opens models (evidence: `include/janas/llm.h`)
- Model loading → GPU execution: uses (evidence: `src/llm/model_load.c`)
- User → Model downloader: requests model
- Model downloader → Model catalog: selects from (evidence: `src/get/main.c`)
- Model downloader → Hugging Face: downloads from (evidence: `src/get/main.c`)
- MCP client app → Model MCP server: starts (evidence: `src/mcp/main.c`)
- Model MCP server → MCP stdio server: serves over stdio
- MCP client app → MCP client: connects through
- Chat tool flow → MCP client: uses
- Flight tools → MCP stdio server: registers tools
- Map tools → MCP stdio server: registers tools
- Weather tools → MCP stdio server: registers tools
- Git tools → MCP stdio server: registers tools
- GitHub tools → MCP stdio server: registers tools
- Price tools → MCP stdio server: registers tools
- Earthquake tools → MCP stdio server: registers tools
- System tools → MCP stdio server: registers tools
- Wiki tools → MCP stdio server: registers tools
