@@ -16,6 +16,110 @@ This document outlines a comprehensive plan to migrate the TechStacks web applic
1616
1717---
1818
19+ ## 🎯 CRITICAL: ALL DATA FLOWS THROUGH EXISTING C# APIS
20+
21+ ** This Next.js application is a pure UI layer with ZERO independent data sources.**
22+
23+ ### Data Source Architecture
24+
25+ ✅ ** What the Next.js app DOES:**
26+ - Renders beautiful, modern React UI
27+ - Handles client-side routing and navigation
28+ - Manages UI state (loading, modals, forms)
29+ - Caches API responses for performance
30+ - Handles authentication session display
31+
32+ ❌ ** What the Next.js app DOES NOT do:**
33+ - ❌ Direct database access
34+ - ❌ Independent REST APIs
35+ - ❌ GraphQL layer
36+ - ❌ Custom data processing/transformation
37+ - ❌ Bypassing ServiceStack in any way
38+
39+ ### Every Single Piece of Data Comes From C# ServiceStack APIs
40+
41+ | Data Type | Source API Endpoint | Section Reference |
42+ | -----------| -------------------| -------------------|
43+ | ** Technologies** | ` GetTechnology ` , ` GetAllTechnologies ` , ` QueryTechnology ` | Section 4.2 |
44+ | ** Tech Stacks** | ` GetTechnologyStack ` , ` GetAllTechnologyStacks ` | Section 4.2 |
45+ | ** Posts** | ` QueryPosts ` , ` GetPost ` , ` CreatePost ` , ` UpdatePost ` | Section 4.2 |
46+ | ** Comments** | ` GetPostComments ` , ` CreatePostComment ` , ` UpdatePostComment ` | Section 4.2 |
47+ | ** Organizations** | ` GetOrganizationBySlug ` , ` GetOrganizationById ` | Section 4.2 |
48+ | ** Users** | ` GetUserInfo ` , ` GetUserFeed ` , ` GetUserOrganizations ` | Section 4.2 |
49+ | ** Authentication** | ` Authenticate ` , ` SessionInfo ` | Section 6 |
50+ | ** Favorites** | ` AddFavoriteTechnology ` , ` RemoveFavoriteTechnology ` | Section 4.2 |
51+ | ** Votes** | ` UserPostVote ` , ` UserPostCommentVote ` | Section 4.2 |
52+ | ** Search** | ` QueryTechnology ` , ` QueryTechStacks ` , ` QueryPosts ` | Section 4.2 |
53+ | ** Configuration** | ` GetConfig ` , ` Overview ` | Section 4.2 |
54+
55+ ### Data Flow Diagram
56+
57+ ```
58+ ┌─────────────────────────────────────────────────┐
59+ │ Next.js React Components (UI Only) │
60+ │ ├─ Display data from props/state │
61+ │ ├─ Handle user interactions │
62+ │ └─ Trigger API calls via gateway │
63+ └────────────────┬────────────────────────────────┘
64+ │
65+ ↓
66+ ┌─────────────────────────────────────────────────┐
67+ │ Zustand Store (Client-side Cache Only) │
68+ │ ├─ Caches API responses temporarily │
69+ │ ├─ Stores user session from C# API │
70+ │ └─ NO independent data processing │
71+ └────────────────┬────────────────────────────────┘
72+ │
73+ ↓
74+ ┌─────────────────────────────────────────────────┐
75+ │ Gateway Layer (lib/api/gateway.ts) │
76+ │ ├─ Thin wrapper around JsonServiceClient │
77+ │ ├─ Maps function calls to DTO requests │
78+ │ └─ NO business logic │
79+ └────────────────┬────────────────────────────────┘
80+ │
81+ ↓
82+ ┌─────────────────────────────────────────────────┐
83+ │ @servicestack/client (JsonServiceClient) │
84+ │ ├─ HTTP calls to /api/* endpoints │
85+ │ ├─ Serializes DTOs to JSON │
86+ │ └─ Handles authentication cookies │
87+ └────────────────┬────────────────────────────────┘
88+ │
89+ ↓
90+ ┌─────────────────────────────────────────────────┐
91+ │ C# ServiceStack Backend ← ALL DATA HERE │
92+ │ ├─ ServiceStack Services (business logic) │
93+ │ ├─ AutoQuery (dynamic queries) │
94+ │ ├─ Validation & Authorization │
95+ │ ├─ OrmLite + Entity Framework │
96+ │ └─ PostgreSQL Database │
97+ └─────────────────────────────────────────────────┘
98+ ```
99+
100+ ### API Integration Guarantee
101+
102+ ** Every API call in the Next.js app follows this pattern:**
103+
104+ ``` typescript
105+ // 1. Import typed DTO from C# project
106+ import { GetTechnology } from ' @/shared/dtos' ;
107+
108+ // 2. Import gateway method (wrapper around JsonServiceClient)
109+ import * as gateway from ' @/lib/api/gateway' ;
110+
111+ // 3. Call C# API - no alternative data sources
112+ export async function loadTechnology(slug : string ) {
113+ // This calls: https://techstacks.io/api/GetTechnology?slug=typescript
114+ const response = await gateway .getTechnology (slug );
115+ return response .result ; // Data comes directly from C# API
116+ }
117+ ```
118+
119+ ** The DTOs (` shared/dtos.ts ` ) are auto-generated from the C# project** - ensuring the Next.js app cannot deviate from the ServiceStack API contract.
120+
121+ ---
122+
19123## Table of Contents
20124
211251 . [ Project Structure & Setup] ( #1-project-structure--setup )
0 commit comments