Skip to main content

Introduction to HocChungKhoan CMS

Welcome to the technical documentation site for HocChungKhoan CMS API Service. This system acts as the API Gateway and Content Management System (CMS) serving the HocChungKhoan frontend application.

The system provides high-performance APIs to query customer profiles, portfolio holdings, stock transaction history, investment performance statistics, and in-depth trading style analytics.


🏗️ System Architecture

The system is designed with a modern serverless architecture consisting of the following key components:

  1. Neon Postgres (Source of Truth): Stores the raw transaction records and master customer profiles.
  2. Insforge Postgres (Serving Database): An edge-replicated database enabling low-latency queries.
  3. Cloudflare Worker (API Layer): Built with Hono and Chanfana, responsible for handling API logic, pagination, filtering, and auto-generating the OpenAPI Spec.
  4. Astro Frontend: The client application displaying charts, dashboards, and reports to end-users.
graph TD
subgraph Cloud
A[Neon Postgres DB] -->|Sync Data| B[Insforge Edge DB]
end
subgraph API Layer
B <-->|Query| C[Cloudflare Worker API]
end
subgraph Client
C <-->|JSON API| D[Astro Frontend]
end

⚡ Key Features

  • Customer Profiles: Retrieve contact information and associated brokerage accounts.
  • Portfolio Holdings: Real-time tracking of stock codes, quantities, average cost, and total value.
  • Transaction History: Advanced filtering by stock symbol, broker code, date ranges, and pagination.
  • Performance Statistics (Stats): Compute total buy/sell values, transaction fees, taxes, and realized P&L.
  • Trading Analytics: Calculate Win Rate, Profit Factor, average holding periods, and monthly trade frequencies.
  • All-in-one Aggregation (Aggregate): Bundle all of the above data points into a single HTTP request to optimize page load speeds on the client application.