Skip to content

Commit 9f0ed22

Browse files
hemanandrclaude
andcommitted
docs: add comprehensive project architecture diagram
- Complete mermaid diagram mapping frontend-backend relationships - API endpoint mappings and data flow documentation - Component dependency trees and service relationships - Architectural patterns summary and integration points 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2f390ce commit 9f0ed22

File tree

1 file changed

+346
-0
lines changed

1 file changed

+346
-0
lines changed

project-architecture.md

Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
# ThingConnect.Pulse - Complete Architecture Diagram
2+
3+
## Project Architecture Overview
4+
5+
```mermaid
6+
graph TB
7+
%% Frontend Layer
8+
subgraph "Frontend (React + Chakra UI)"
9+
subgraph "Pages"
10+
Dashboard[Dashboard.tsx]
11+
History[History.tsx]
12+
Configuration[Configuration.tsx]
13+
Settings[Settings.tsx]
14+
Login[LoginPage.tsx]
15+
Onboarding[OnboardingPage.tsx]
16+
EndpointDetail[EndpointDetail.tsx]
17+
end
18+
19+
subgraph "Components"
20+
StatusTable[StatusTable.tsx]
21+
StatusFilters[StatusFilters.tsx]
22+
AvailabilityChart[AvailabilityChart.tsx]
23+
ConfigEditor[ConfigurationEditor.tsx]
24+
HistoryTable[HistoryTable.tsx]
25+
Navigation[Navigation.tsx]
26+
end
27+
28+
subgraph "API Services"
29+
StatusService[StatusService.ts]
30+
HistoryService[HistoryService.ts]
31+
ConfigService[ConfigurationService.ts]
32+
AuthService[AuthService.ts]
33+
ApiClient[ApiClient.ts]
34+
end
35+
36+
subgraph "Hooks & Utils"
37+
useStatusQuery[useStatusQuery.ts]
38+
useAnalytics[useAnalytics.ts]
39+
AuthContext[AuthContext.tsx]
40+
Analytics[manufacturingAnalytics.ts]
41+
end
42+
end
43+
44+
%% API Layer
45+
subgraph "API Endpoints (REST)"
46+
Auth["/api/auth/*"]
47+
Status["/api/status/*"]
48+
Config["/api/configuration/*"]
49+
HistoryAPI["/api/history/*"]
50+
UserMgmt["/api/usermanagement/*"]
51+
end
52+
53+
%% Backend Layer
54+
subgraph "Backend (ASP.NET Core)"
55+
subgraph "Controllers"
56+
AuthController[AuthController.cs]
57+
StatusController[StatusController.cs]
58+
ConfigController[ConfigurationController.cs]
59+
HistoryController[HistoryController.cs]
60+
UserController[UserManagementController.cs]
61+
end
62+
63+
subgraph "Business Services"
64+
ConfigServiceBE[ConfigurationService.cs]
65+
StatusServiceBE[StatusService.cs]
66+
HistoryServiceBE[HistoryService.cs]
67+
ProbeService[ProbeService.cs]
68+
OutageDetection[OutageDetectionService.cs]
69+
Discovery[DiscoveryService.cs]
70+
end
71+
72+
subgraph "Background Services"
73+
MonitoringBG[MonitoringBackgroundService.cs]
74+
RollupBG[RollupBackgroundService.cs]
75+
LogCleanup[LogCleanupBackgroundService.cs]
76+
end
77+
78+
subgraph "Data Services"
79+
RollupService[RollupService.cs]
80+
PruneService[PruneService.cs]
81+
SettingsService[SettingsService.cs]
82+
PathService[PathService.cs]
83+
end
84+
85+
subgraph "Infrastructure"
86+
SentryService[ConsentAwareSentryService.cs]
87+
ConfigParser[ConfigurationParser.cs]
88+
PlainTextFormatter[PlainTextInputFormatter.cs]
89+
end
90+
end
91+
92+
%% Data Layer
93+
subgraph "Data Layer (SQLite + EF Core)"
94+
subgraph "Entities"
95+
Group[Group.cs]
96+
Endpoint[Endpoint.cs]
97+
CheckResult[CheckResultRaw.cs]
98+
Outage[Outage.cs]
99+
Rollup15m[Rollup15m.cs]
100+
RollupDaily[RollupDaily.cs]
101+
Setting[Setting.cs]
102+
ConfigVersion[ConfigVersion.cs]
103+
AppUser[ApplicationUser.cs]
104+
end
105+
106+
DbContext[PulseDbContext.cs]
107+
SQLiteDB[(SQLite Database)]
108+
end
109+
110+
%% External Services
111+
subgraph "External"
112+
Sentry[Sentry.io<br/>Error Monitoring]
113+
Mixpanel[Mixpanel<br/>Analytics]
114+
Network[Network Endpoints<br/>ICMP/TCP/HTTP]
115+
end
116+
117+
%% Frontend to API Connections
118+
Dashboard -->|GET /api/status/live| Status
119+
History -->|GET /api/history/endpoint/{id}| HistoryAPI
120+
Configuration -->|GET,POST /api/configuration/*| Config
121+
Settings -->|CRUD /api/usermanagement/*| UserMgmt
122+
Login -->|POST /api/auth/login| Auth
123+
Onboarding -->|POST /api/auth/register| Auth
124+
125+
%% Service Layer Connections
126+
StatusService -->|HTTP Calls| ApiClient
127+
HistoryService -->|HTTP Calls| ApiClient
128+
ConfigService -->|HTTP Calls| ApiClient
129+
AuthService -->|HTTP Calls| ApiClient
130+
131+
%% API to Backend Connections
132+
Auth --> AuthController
133+
Status --> StatusController
134+
Config --> ConfigController
135+
HistoryAPI --> HistoryController
136+
UserMgmt --> UserController
137+
138+
%% Backend Service Dependencies
139+
AuthController --> SettingsService
140+
StatusController --> StatusServiceBE
141+
ConfigController --> ConfigServiceBE
142+
HistoryController --> HistoryServiceBE
143+
UserController --> DbContext
144+
145+
%% Business Service Dependencies
146+
StatusServiceBE --> DbContext
147+
StatusServiceBE --> OutageDetection
148+
HistoryServiceBE --> DbContext
149+
ConfigServiceBE --> ConfigParser
150+
ConfigServiceBE --> DbContext
151+
152+
%% Background Services
153+
MonitoringBG --> ProbeService
154+
MonitoringBG --> OutageDetection
155+
MonitoringBG --> StatusServiceBE
156+
RollupBG --> RollupService
157+
LogCleanup --> PathService
158+
159+
%% Monitoring Pipeline
160+
ProbeService -->|Network Probes| Network
161+
ProbeService --> CheckResult
162+
OutageDetection --> Outage
163+
OutageDetection --> CheckResult
164+
165+
%% Data Flow
166+
RollupService --> CheckResult
167+
RollupService --> Rollup15m
168+
RollupService --> RollupDaily
169+
PruneService --> CheckResult
170+
171+
%% Database Relationships
172+
DbContext --> Group
173+
DbContext --> Endpoint
174+
DbContext --> CheckResult
175+
DbContext --> Outage
176+
DbContext --> Rollup15m
177+
DbContext --> RollupDaily
178+
DbContext --> Setting
179+
DbContext --> ConfigVersion
180+
DbContext --> AppUser
181+
DbContext --> SQLiteDB
182+
183+
%% External Service Connections
184+
SentryService -->|Error Reports| Sentry
185+
Analytics -->|Usage Events| Mixpanel
186+
187+
%% React Hooks
188+
Dashboard --> useStatusQuery
189+
History --> useAnalytics
190+
Configuration --> useAnalytics
191+
useStatusQuery --> StatusService
192+
193+
%% Authentication Flow
194+
AuthContext --> AuthService
195+
Navigation --> AuthContext
196+
197+
%% Styling
198+
classDef frontend fill:#e1f5fe
199+
classDef backend fill:#f3e5f5
200+
classDef data fill:#e8f5e8
201+
classDef external fill:#fff3e0
202+
classDef api fill:#fce4ec
203+
204+
class Dashboard,History,Configuration,Settings,Login,Onboarding,EndpointDetail,StatusTable,StatusFilters,AvailabilityChart,ConfigEditor,HistoryTable,Navigation frontend
205+
class AuthController,StatusController,ConfigController,HistoryController,UserController,ConfigServiceBE,StatusServiceBE,HistoryServiceBE,ProbeService,OutageDetection,Discovery,MonitoringBG,RollupBG,LogCleanup,RollupService,PruneService,SettingsService,PathService,SentryService,ConfigParser backend
206+
class Group,Endpoint,CheckResult,Outage,Rollup15m,RollupDaily,Setting,ConfigVersion,AppUser,DbContext,SQLiteDB data
207+
class Sentry,Mixpanel,Network external
208+
class Auth,Status,Config,HistoryAPI,UserMgmt api
209+
```
210+
211+
## API Relationship Matrix
212+
213+
```mermaid
214+
graph LR
215+
subgraph "Frontend Services → Backend APIs"
216+
FS1[StatusService] -->|GET /api/status/live<br/>Query: group, search| API1[StatusController.GetLive]
217+
FS2[HistoryService] -->|GET /api/history/endpoint/{id}<br/>Query: from, to, bucket| API2[HistoryController.GetEndpoint]
218+
FS3[ConfigurationService] -->|GET /api/configuration/versions<br/>GET /api/configuration/current<br/>POST /api/configuration/apply| API3[ConfigurationController]
219+
FS4[AuthService] -->|POST /api/auth/login<br/>POST /api/auth/register<br/>GET /api/auth/session<br/>POST /api/auth/logout| API4[AuthController]
220+
FS5[UserManagement] -->|GET /api/usermanagement/<br/>POST /api/usermanagement/<br/>PUT /api/usermanagement/{id}| API5[UserManagementController]
221+
end
222+
```
223+
224+
## Data Flow Architecture
225+
226+
```mermaid
227+
sequenceDiagram
228+
participant U as User
229+
participant F as Frontend
230+
participant API as API Layer
231+
participant S as Services
232+
participant BG as Background
233+
participant DB as Database
234+
participant N as Network
235+
236+
Note over U,N: Live Monitoring Flow
237+
U->>F: Access Dashboard
238+
F->>API: GET /api/status/live
239+
API->>S: StatusService.GetLive()
240+
S->>DB: Query latest status
241+
DB-->>S: Return endpoint data
242+
S-->>API: PagedLive response
243+
API-->>F: JSON response
244+
F-->>U: Real-time dashboard
245+
246+
Note over BG,N: Background Monitoring
247+
loop Every Interval
248+
BG->>N: ICMP/TCP/HTTP Probe
249+
N-->>BG: Response/Timeout
250+
BG->>DB: Store CheckResult
251+
BG->>S: Update OutageDetection
252+
S->>DB: Store/Update Outage
253+
end
254+
255+
Note over U,DB: Configuration Flow
256+
U->>F: Upload YAML Config
257+
F->>API: POST /api/configuration/apply
258+
API->>S: ConfigurationService.Apply()
259+
S->>S: Parse & Validate YAML
260+
S->>DB: Update Groups & Endpoints
261+
S->>DB: Store ConfigVersion
262+
S-->>API: Success/Validation Errors
263+
API-->>F: Response
264+
F-->>U: Confirmation/Errors
265+
```
266+
267+
## Component Dependency Tree
268+
269+
```mermaid
270+
graph TD
271+
%% Frontend Dependencies
272+
App[App.tsx] --> Router[Router]
273+
App --> AuthContext
274+
App --> QueryProvider[TanStack Query Provider]
275+
276+
Router --> Dashboard
277+
Router --> History
278+
Router --> Configuration
279+
Router --> Settings
280+
Router --> Login
281+
282+
Dashboard --> StatusTable
283+
Dashboard --> StatusFilters
284+
Dashboard --> useStatusQuery
285+
286+
StatusTable --> StatusService
287+
StatusTable --> useAnalytics
288+
289+
History --> HistoryTable
290+
History --> HistoryService
291+
History --> DateRangePicker
292+
293+
Configuration --> ConfigEditor
294+
Configuration --> ConfigService
295+
Configuration --> useAnalytics
296+
297+
%% Backend Dependencies
298+
Program[Program.cs] --> Controllers
299+
Program --> Services
300+
Program --> BackgroundServices
301+
Program --> DbContext
302+
Program --> Identity
303+
304+
Controllers --> BusinessServices
305+
BusinessServices --> DataServices
306+
BusinessServices --> DbContext
307+
BackgroundServices --> BusinessServices
308+
BackgroundServices --> NetworkServices
309+
310+
%% Data Dependencies
311+
DbContext --> Entities
312+
Entities --> SQLiteDB
313+
```
314+
315+
## Key Architectural Patterns Summary
316+
317+
1. **Frontend Patterns:**
318+
- Component Composition with Chakra UI
319+
- Custom Hooks for business logic
320+
- Service Layer for API abstraction
321+
- TanStack Query for server state
322+
- Context API for authentication
323+
324+
2. **Backend Patterns:**
325+
- Controller → Service → Repository (EF Core)
326+
- Dependency Injection throughout
327+
- Background Services for long-running tasks
328+
- Configuration-driven external settings
329+
330+
3. **API Patterns:**
331+
- RESTful endpoints with proper HTTP verbs
332+
- Cookie-based authentication
333+
- JSON request/response with text/plain for YAML
334+
- Proper error handling and validation
335+
336+
4. **Data Patterns:**
337+
- Code-first EF Core with migrations
338+
- Time-series data with rollup aggregation
339+
- Hierarchical grouping with foreign keys
340+
- Soft delete patterns for users
341+
342+
5. **Integration Patterns:**
343+
- Polling-based real-time updates (5s intervals)
344+
- Client-side CSV generation
345+
- Consent-aware external service integration
346+
- Network probing with configurable retry logic

0 commit comments

Comments
 (0)