Skip to content

Commit e02986a

Browse files
committed
Enhance README.md with detailed architecture diagram and update AI provider information
1 parent 32302fc commit e02986a

File tree

1 file changed

+79
-12
lines changed

1 file changed

+79
-12
lines changed

README.md

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,105 @@
22

33
Aspire AI Chat is a full-stack chat sample that combines modern technologies to deliver a ChatGPT-like experience.
44

5+
## Architecture
6+
7+
```mermaid
8+
graph TB
9+
User[User Browser]
10+
11+
subgraph "YARP Reverse Proxy"
12+
YARP[chatui - YARP]
13+
end
14+
15+
subgraph "Frontend"
16+
UI[React + TypeScript UI<br/>Vite Build]
17+
end
18+
19+
subgraph "Backend API"
20+
API[ChatApi - ASP.NET Core<br/>SignalR Hub]
21+
end
22+
23+
subgraph "Data Layer"
24+
PG[(PostgreSQL<br/>Conversation History)]
25+
Redis[(Redis<br/>Message Stream Cache)]
26+
end
27+
28+
subgraph "AI Layer"
29+
LLM{AI Provider}
30+
Ollama[Ollama<br/>phi4 model<br/>Linux/Windows]
31+
OpenAI[OpenAI<br/>gpt-4.1<br/>macOS/Production]
32+
end
33+
34+
User -->|HTTP/WS| YARP
35+
YARP -->|Static Files| UI
36+
YARP -->|/api/*| API
37+
38+
API -->|SignalR| User
39+
API -->|EF Core| PG
40+
API -->|Pub/Sub| Redis
41+
API -->|IChatClient| LLM
42+
43+
LLM -.->|Local| Ollama
44+
LLM -.->|Cloud| OpenAI
45+
46+
style YARP fill:#e1f5ff
47+
style API fill:#fff3e0
48+
style UI fill:#f3e5f5
49+
style PG fill:#e8f5e9
50+
style Redis fill:#ffebee
51+
style LLM fill:#fff9c4
52+
```
53+
554
## High-Level Overview
655

756
- **Backend API:**
8-
The backend is built with **ASP.NET Core** and interacts with an LLM using **Microsoft.Extensions.AI**. It leverages `IChatClient` to abstract the interaction between the API and the model. Chat responses are streamed back to the client using stream JSON array responses.
57+
The backend is built with **ASP.NET Core** and interacts with an LLM using **Microsoft.Extensions.AI**. It leverages `IChatClient` to abstract the interaction between the API and the model. Chat responses are streamed back to the client using **SignalR** for real-time communication.
958

1059
- **Data & Persistence:**
11-
Uses **Entity Framework Core** with **PostgreSQL** for reliable relational data storage. The project includes database migrations for easy setup and version control of the schema.
60+
Uses **Entity Framework Core** with **PostgreSQL** for reliable relational data storage. **Redis** is used for caching and broadcasting live message streams across multiple clients.
1261

1362
- **AI & Chat Capabilities:**
14-
- Uses **Ollama** (via OllamaSharp) for local inference, enabling context-aware responses.
15-
- In production, the application switches to [**OpenAI**](https://openai.com/) for LLM capabilities.
63+
- Uses **Ollama** (via OllamaSharp) for local inference on Linux/Windows.
64+
- On macOS, the application uses [**OpenAI**](https://openai.com/) directly for better compatibility.
65+
- In production, the application can be configured to use various AI providers through the abstraction layer.
1666

1767
- **Frontend UI:**
18-
Built with **React**, the user interface offers a modern and interactive chat experience. The React application is built and hosted using [**Caddy**](https://caddyserver.com/).
68+
Built with **React** and **TypeScript** using **Vite** for fast development and builds. The UI provides a modern chat interface with support for markdown rendering and conversation history.
69+
70+
- **Reverse Proxy & Serving:**
71+
Uses **YARP** (Yet Another Reverse Proxy) to serve the static frontend and proxy API requests, providing a unified endpoint.
1972

2073
## Getting Started
2174

2275
### Prerequisites
2376

24-
- [.NET 9.0](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)
77+
- [.NET 10.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)
2578
- [Docker](https://www.docker.com/get-started) or [Podman](https://podman-desktop.io/)
2679
- [Node.js](https://nodejs.org/) (LTS version recommended)
2780

2881
### Running the Application
2982

30-
Run the [AIChat.AppHost](AIChat.AppHost) project. This project uses
31-
[.NET Aspire](https://learn.microsoft.com/en-us/dotnet/aspire/get-started/aspire-overview)
32-
to run the application in a container.
83+
Run the [AIChat.AppHost](AIChat.AppHost) project using the .NET Aspire tooling:
84+
85+
```bash
86+
aspire run
87+
```
88+
89+
This project uses [.NET Aspire](https://learn.microsoft.com/en-us/dotnet/aspire/get-started/aspire-overview) to orchestrate the application components in containers.
3390

3491
### Configuration
3592

36-
- By default, the application uses **Ollama** for local inference.
37-
- To use **OpenAI**, set the appropriate configuration values (e.g., API keys, endpoints).
38-
- The PostgreSQL database will be automatically created and migrated when running with Aspire.
93+
- By default, the application uses **Ollama** (phi4 model) for local inference on Linux/Windows.
94+
- On **macOS**, it automatically switches to **OpenAI** and will prompt for your OpenAI API key if not already configured.
95+
- The **PostgreSQL** database and **Redis** cache are automatically provisioned when running with Aspire.
96+
- Access the Aspire dashboard to monitor resources and view logs.
97+
98+
## CI/CD
99+
100+
The project includes a GitHub Actions workflow that:
101+
102+
- Builds container images for both the API and UI
103+
- Tags images with format: `<branch>-<build-number>-<git-sha>`
104+
- Pushes images to GitHub Container Registry (GHCR)
39105

106+
Images are available at: `ghcr.io/<owner>/chatapi` and `ghcr.io/<owner>/chatui`

0 commit comments

Comments
 (0)