# skystates-official/sky-states architecture

> Architecture diagram of the GitHub repository skystates-official/sky-states, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/skystates-official/sky-states
- Repository: https://github.com/skystates-official/sky-states

## Overview

#### Purpose and entry points
Astro-based marketing, program catalog, career-content, and checkout site for Sky States training programs. Page rendering starts in `src/pages/index.astro`, program pages under `src/pages/programs/`, and broad legacy/content URL handling in `src/pages/[...slug].astro`. Shared document structure is in `src/layouts/Layout.astro`.

#### Site composition and shared UX
Reusable navigation, footer, branding, consultation capture, cache protection, and third-party chat are componentized. `src/components/Header.astro` and `src/components/Footer.astro` frame pages; `src/components/ConsultationModal.astro` drives lead capture; `src/components/ZohoSalesIQ.astro` embeds Zoho SalesIQ. Global visual styling is centralized in `src/styles/global.css`.

#### Content and program domain
Most marketing content is file-backed JSON/JS rather than a separate CMS service: programs, homepage blocks, FAQs, stories, jobs, and tool/employer imagery are sourced from `src/data/programs.json`, `src/data/homepage.json`, and `src/content/jobs/`. Program-specific rendered experiences live in `src/pages/programs/cyber-security.astro`, `src/pages/programs/data-science-ai.astro`, and `src/pages/programs/devops.astro`.

#### Backend API boundary
Astro API routes provide mutable/admin-facing operations and frontend form endpoints. CMS/page/media operations are exposed through `src/pages/api/cms.js`, `src/pages/api/pages.js`, and `src/pages/api/media.js`; lead and finance-related requests use `src/pages/api/consultation.js` and `src/pages/api/emi-request.js`. `src/middleware.js` is the request-wide control boundary.

#### Commerce and enrollment flow
Checkout pages initiate paid or free enrollment, then delegate pricing, coupon validation, Stripe session/payment-intent creation, and webhook fulfillment to server-side libraries. The UI flow is `src/pages/checkout.astro` → `src/pages/api/payments/create-checkout-session.js` or `src/pages/api/payments/create-intent.js` → `src/pages/api/payments/webhook.js`; core logic resides in `src/lib/checkout.js`, `src/lib/stripe-checkout.js`, and `src/lib/orders.js`. Coupon rules are represented by `src/data/coupon-config.json` and enforced through `src/lib/coupons.js`.

#### Persistence and external integrations
Local application persistence is SQLite-oriented, with connection/schema access in `src/db/sqlite.js` and authentication support in `src/db/auth.js`. Stripe is the payment provider (`src/lib/stripe.js`), transactional/notification behavior is isolated in `src/lib/email.js`, and Zoho SalesIQ is the live-chat external service. Decap CMS administrative assets/configuration are hosted statically at `public/admin/decap.html` and `public/admin/config.yml`.

#### Delivery and static assets
The application is containerized via `Dockerfile` and `docker-compose.yml`. Astro build/runtime behavior is configured in `astro.config.mjs`. Public PDFs, video, certificates, and SEO crawl artifacts are served directly from `public/`, including `public/sitemap.xml` and `public/robots.txt`.

Main entry points: [`src/lib/checkout.js`](https://github.com/skystates-official/sky-states/blob/main/src/lib/checkout.js) (Checkout & Orders), [`src/layouts/Layout.astro`](https://github.com/skystates-official/sky-states/blob/main/src/layouts/Layout.astro) (Shared Layout), [`src/pages/index.astro`](https://github.com/skystates-official/sky-states/blob/main/src/pages/index.astro) (Homepage), [`src/components/Header.astro`](https://github.com/skystates-official/sky-states/blob/main/src/components/Header.astro) (Shared UX)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_site["Astro Site"]
  node_home["Homepage<br/>Astro page<br/>[index.astro]"]
  node_program_pages["Program Pages<br/>Astro routes"]
  node_legacy_routes["Content URL Fallback<br/>catch-all route<br/>[&#91;...slug&#93;.astro]"]
  node_layout["Shared Layout<br/>Astro layout<br/>[Layout.astro]"]
  node_shared_ui["Shared UX<br/>Astro components<br/>[Header.astro]"]
  node_global_styles["Global Styles<br/>CSS<br/>[global.css]"]
end

subgraph group_api["Server APIs"]
  node_middleware{{"Request Middleware<br/>Astro middleware<br/>[middleware.js]"}}
  node_cms_api["CMS &amp; Media APIs<br/>Astro API routes<br/>[cms.js]"]
  node_lead_api["Lead &amp; Finance APIs<br/>Astro API routes<br/>[consultation.js]"]
end

subgraph group_commerce["Enrollment &amp; Payments"]
  node_checkout_page["Checkout<br/>Astro page<br/>[checkout.astro]"]
  node_payment_api["Payment APIs<br/>Astro API routes"]
  node_payment_webhook["Stripe Webhook<br/>Astro API route<br/>[webhook.js]"]
  node_checkout_logic["Checkout &amp; Orders<br/>server libraries<br/>[checkout.js]"]
end

subgraph group_data["Content &amp; Persistence"]
  node_coupon_rules["Coupon Rules<br/>JSON configuration<br/>[coupon-config.json]"]
  node_marketing_content["Marketing Content<br/>file-backed content<br/>[programs.json]"]
  node_sqlite[("SQLite Persistence<br/>database access<br/>[sqlite.js]")]
end

subgraph group_external["External &amp; Delivery"]
  node_stripe{{"Stripe<br/>payment provider<br/>[stripe.js]"}}
  node_notifications["Email Notifications<br/>email integration<br/>[email.js]"]
  node_zoho{{"Zoho SalesIQ<br/>live chat service<br/>[ZohoSalesIQ.astro]"}}
  node_decap["Decap CMS Admin<br/>static admin assets<br/>[decap.html]"]
  node_deployment["Container Delivery<br/>Docker deployment"]
end

node_home -->|"renders in"| node_layout
node_program_pages -->|"renders in"| node_layout
node_legacy_routes -->|"renders in"| node_layout
node_layout -->|"composes"| node_shared_ui
node_layout -->|"uses"| node_global_styles
node_shared_ui -->|"embeds"| node_zoho
node_home -->|"reads"| node_marketing_content
node_program_pages -->|"reads"| node_marketing_content
node_middleware -.->|"guards requests to"| node_home
node_middleware -.->|"controls requests to"| node_cms_api
node_shared_ui -->|"submits consultation"| node_lead_api
node_lead_api -->|"persists leads"| node_sqlite
node_lead_api -->|"sends notifications"| node_notifications
node_decap -->|"manages content through"| node_cms_api
node_checkout_page -->|"starts payment"| node_payment_api
node_payment_api -->|"delegates to"| node_checkout_logic
node_checkout_logic -->|"validates"| node_coupon_rules
node_checkout_logic -->|"creates payment"| node_stripe
node_stripe -->|"sends events"| node_payment_webhook
node_payment_webhook -->|"fulfills through"| node_checkout_logic
node_checkout_logic -->|"stores orders"| node_sqlite
node_checkout_logic -->|"sends enrollment email"| node_notifications
node_deployment -.->|"serves"| node_home

click node_home "https://github.com/skystates-official/sky-states/blob/main/src/pages/index.astro"
click node_program_pages "https://github.com/skystates-official/sky-states/blob/main/src/pages/programs/cyber-security.astro"
click node_legacy_routes "https://github.com/skystates-official/sky-states/blob/main/src/pages/%5B...slug%5D.astro"
click node_layout "https://github.com/skystates-official/sky-states/blob/main/src/layouts/Layout.astro"
click node_shared_ui "https://github.com/skystates-official/sky-states/blob/main/src/components/Header.astro"
click node_global_styles "https://github.com/skystates-official/sky-states/blob/main/src/styles/global.css"
click node_middleware "https://github.com/skystates-official/sky-states/blob/main/src/middleware.js"
click node_cms_api "https://github.com/skystates-official/sky-states/blob/main/src/pages/api/cms.js"
click node_lead_api "https://github.com/skystates-official/sky-states/blob/main/src/pages/api/consultation.js"
click node_checkout_page "https://github.com/skystates-official/sky-states/blob/main/src/pages/checkout.astro"
click node_payment_api "https://github.com/skystates-official/sky-states/blob/main/src/pages/api/payments/create-checkout-session.js"
click node_payment_webhook "https://github.com/skystates-official/sky-states/blob/main/src/pages/api/payments/webhook.js"
click node_checkout_logic "https://github.com/skystates-official/sky-states/blob/main/src/lib/checkout.js"
click node_coupon_rules "https://github.com/skystates-official/sky-states/blob/main/src/data/coupon-config.json"
click node_marketing_content "https://github.com/skystates-official/sky-states/blob/main/src/data/programs.json"
click node_sqlite "https://github.com/skystates-official/sky-states/blob/main/src/db/sqlite.js"
click node_stripe "https://github.com/skystates-official/sky-states/blob/main/src/lib/stripe.js"
click node_notifications "https://github.com/skystates-official/sky-states/blob/main/src/lib/email.js"
click node_zoho "https://github.com/skystates-official/sky-states/blob/main/src/components/ZohoSalesIQ.astro"
click node_decap "https://github.com/skystates-official/sky-states/blob/main/public/admin/decap.html"
click node_deployment "https://github.com/skystates-official/sky-states/blob/main/Dockerfile"

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_home,node_program_pages,node_legacy_routes,node_layout,node_shared_ui,node_global_styles toneBlue
class node_middleware,node_cms_api,node_lead_api toneAmber
class node_checkout_page,node_payment_api,node_payment_webhook,node_checkout_logic toneMint
class node_coupon_rules,node_marketing_content,node_sqlite toneRose
class node_stripe,node_notifications,node_zoho,node_decap,node_deployment toneIndigo
```

## Components

### Astro Site

- [Homepage](https://github.com/skystates-official/sky-states/blob/main/src/pages/index.astro): Astro page · `src/pages/index.astro`
- [Program Pages](https://github.com/skystates-official/sky-states/blob/main/src/pages/programs/cyber-security.astro): Astro routes · Program-specific marketing experiences. · `src/pages/programs/cyber-security.astro`
- [Content URL Fallback](https://github.com/skystates-official/sky-states/blob/main/src/pages/%5B...slug%5D.astro): catch-all route · Handles broad legacy and content URLs. · `src/pages/[...slug].astro`
- [Shared Layout](https://github.com/skystates-official/sky-states/blob/main/src/layouts/Layout.astro): Astro layout · `src/layouts/Layout.astro`
- [Shared UX](https://github.com/skystates-official/sky-states/blob/main/src/components/Header.astro): Astro components · Navigation, footer, consultation capture, and chat embed. · `src/components/Header.astro`
- [Global Styles](https://github.com/skystates-official/sky-states/blob/main/src/styles/global.css): CSS · `src/styles/global.css`

### Server APIs

- [Request Middleware](https://github.com/skystates-official/sky-states/blob/main/src/middleware.js): Astro middleware · Request-wide control boundary. · `src/middleware.js`
- [CMS & Media APIs](https://github.com/skystates-official/sky-states/blob/main/src/pages/api/cms.js): Astro API routes · Admin-facing page, CMS, and media operations. · `src/pages/api/cms.js`
- [Lead & Finance APIs](https://github.com/skystates-official/sky-states/blob/main/src/pages/api/consultation.js): Astro API routes · Consultation and EMI form endpoints. · `src/pages/api/consultation.js`

### Enrollment & Payments

- [Checkout](https://github.com/skystates-official/sky-states/blob/main/src/pages/checkout.astro): Astro page · Starts paid or free enrollment. · `src/pages/checkout.astro`
- [Payment APIs](https://github.com/skystates-official/sky-states/blob/main/src/pages/api/payments/create-checkout-session.js): Astro API routes · Creates Stripe checkout sessions and payment intents. · `src/pages/api/payments/create-checkout-session.js`
- [Stripe Webhook](https://github.com/skystates-official/sky-states/blob/main/src/pages/api/payments/webhook.js): Astro API route · Receives payment fulfillment events. · `src/pages/api/payments/webhook.js`
- [Checkout & Orders](https://github.com/skystates-official/sky-states/blob/main/src/lib/checkout.js): server libraries · Pricing, enrollment, Stripe checkout, and order fulfillment logic. · `src/lib/checkout.js`

### Content & Persistence

- [Coupon Rules](https://github.com/skystates-official/sky-states/blob/main/src/data/coupon-config.json): JSON configuration · `src/data/coupon-config.json`
- [Marketing Content](https://github.com/skystates-official/sky-states/blob/main/src/data/programs.json): file-backed content · Programs, homepage blocks, FAQs, stories, and jobs. · `src/data/programs.json`
- [SQLite Persistence](https://github.com/skystates-official/sky-states/blob/main/src/db/sqlite.js): database access · Local application data and schema access. · `src/db/sqlite.js`

### External & Delivery

- [Stripe](https://github.com/skystates-official/sky-states/blob/main/src/lib/stripe.js): payment provider · `src/lib/stripe.js`
- [Email Notifications](https://github.com/skystates-official/sky-states/blob/main/src/lib/email.js): email integration · Transactional and notification delivery. · `src/lib/email.js`
- [Zoho SalesIQ](https://github.com/skystates-official/sky-states/blob/main/src/components/ZohoSalesIQ.astro): live chat service · `src/components/ZohoSalesIQ.astro`
- [Decap CMS Admin](https://github.com/skystates-official/sky-states/blob/main/public/admin/decap.html): static admin assets · `public/admin/decap.html`
- [Container Delivery](https://github.com/skystates-official/sky-states/blob/main/Dockerfile): Docker deployment · Containerized Astro build and runtime. · `Dockerfile`

## Connections

- Homepage → Shared Layout: renders in
- Program Pages → Shared Layout: renders in
- Content URL Fallback → Shared Layout: renders in
- Shared Layout → Shared UX: composes
- Shared Layout → Global Styles: uses
- Shared UX → Zoho SalesIQ: embeds
- Homepage → Marketing Content: reads
- Program Pages → Marketing Content: reads
- Request Middleware → Homepage: guards requests to
- Request Middleware → CMS & Media APIs: controls requests to
- Shared UX → Lead & Finance APIs: submits consultation
- Lead & Finance APIs → SQLite Persistence: persists leads
- Lead & Finance APIs → Email Notifications: sends notifications
- Decap CMS Admin → CMS & Media APIs: manages content through
- Checkout → Payment APIs: starts payment
- Payment APIs → Checkout & Orders: delegates to
- Checkout & Orders → Coupon Rules: validates
- Checkout & Orders → Stripe: creates payment
- Stripe → Stripe Webhook: sends events
- Stripe Webhook → Checkout & Orders: fulfills through
- Checkout & Orders → SQLite Persistence: stores orders
- Checkout & Orders → Email Notifications: sends enrollment email
- Container Delivery → Homepage: serves
