# hardikkhyal/self-host architecture

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

- Interactive diagram: https://gitdiagram.com/hardikkhyal/self-host
- Repository: https://github.com/hardikkhyal/self-host

## Overview

#### Purpose and entry points
DevOpsHub is a full-stack DevOps/SaaS dashboard for user authentication, project management, server/deployment orchestration, monitoring views, and cloud integrations. The executable application roots are the TypeScript backend at `DevOpsHub/backend/src/server.ts` and Vite/React frontend at `DevOpsHub/frontend/src/main.tsx`, composed by `DevOpsHub/docker-compose.yml`.

#### Frontend application shell
The frontend is a React/TypeScript SPA. `DevOpsHub/frontend/src/App.tsx` selects application pages, while `DevOpsHub/frontend/src/components/layout/AppLayout.tsx` provides persistent navigation via `Navbar.tsx` and `Sidebar.tsx`. Feature pages include projects, servers, monitoring, integrations, and auth under `DevOpsHub/frontend/src/pages/`.

#### Client state and API boundary
The browser communicates with the backend through `DevOpsHub/frontend/src/services/api.ts`. Authentication state is maintained separately in `DevOpsHub/frontend/src/store/authStore.ts`, and user-facing request/error feedback in `DevOpsHub/frontend/src/store/toastStore.ts`. This establishes the client/server boundary: pages render and initiate actions; API services carry authenticated requests to backend routes.

#### HTTP API, authentication, and request control
The backend is a Node.js/TypeScript HTTP service rooted at `DevOpsHub/backend/src/server.ts`. Route modules split the public API into authentication (`DevOpsHub/backend/src/routes/authRoutes.ts`) and project operations (`DevOpsHub/backend/src/routes/projectRoutes.ts`), with controller implementations in `DevOpsHub/backend/src/controllers/authController.ts` and `projectController.ts`. `DevOpsHub/backend/src/middleware/authMiddleware.ts` gates protected operations; rate limiting and centralized error handling are defined in `rateLimiter.ts` and `errorHandler.ts`.

#### Persistence and tenant/domain model
Prisma owns persistence configuration and schema evolution through `DevOpsHub/backend/prisma/schema.prisma` and `DevOpsHub/backend/prisma/migrations/`. The migrations indicate an evolving SaaS model with OTP support and deployment stages. Backend controllers access the shared Prisma client from `DevOpsHub/backend/src/prisma.ts`; seed data is provisioned by `DevOpsHub/backend/prisma/seed.ts`. Database credentials and operational settings are expected through backend environment configuration.

#### Deployment orchestration and cloud integration
Project actions can cross from the API layer into infrastructure execution. `DevOpsHub/backend/src/services/sshOrchestrator.ts` represents remote-server orchestration over SSH, while `DevOpsHub/backend/src/services/awsService.ts` integrates AWS capabilities. Sensitive connection or provider material is protected through `DevOpsHub/backend/src/utils/encryption.ts`; service failures are normalized/logged through `errorClassifier.ts` and `logger.ts`.

#### Infrastructure runtime
Local/container deployment is defined by `DevOpsHub/docker-compose.yml` and the backend image at `DevOpsHub/backend/Dockerfile`. Provisioning artifacts target AWS-oriented infrastructure with Terraform in `DevOpsHub/infrastructure/terraform/main.tf` and host configuration/deployment automation through Ansible in `DevOpsHub/infrastructure/ansible/hosts.ini` and `playbook.yml`. The principal runtime boundaries are browser → HTTP API → Prisma database, plus API → AWS/SSH-managed servers.

Main entry points: [`DevOpsHub/frontend/src/App.tsx`](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/App.tsx) (App shell and pages), [`DevOpsHub/backend/src/controllers/authController.ts`](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/controllers/authController.ts) (Auth and project controllers), [`DevOpsHub/backend/src/server.ts`](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/server.ts) (HTTP server), [`DevOpsHub/frontend/src/main.tsx`](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/main.tsx) (Vite entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React SPA"]
  node_frontend_entry["Vite entry<br/>React entrypoint<br/>[main.tsx]"]
  node_app_shell["App shell and pages<br/>React UI<br/>[App.tsx]"]
  node_layout["Persistent layout<br/>React layout<br/>[AppLayout.tsx]"]
  node_api_client["API client<br/>HTTP client<br/>[api.ts]"]
  node_auth_store["Auth state<br/>client store<br/>[authStore.ts]"]
  node_toast_store["Request feedback<br/>client store<br/>[toastStore.ts]"]
end

subgraph group_backend["Backend API"]
  node_server["HTTP server<br/>Node.js entrypoint<br/>[server.ts]"]
  node_api_routes["Auth and project routes<br/>route modules<br/>[authRoutes.ts]"]
  node_controllers["Auth and project controllers<br/>[authController.ts]"]
  node_request_controls["Auth and error controls<br/>middleware<br/>[authMiddleware.ts]"]
  node_prisma_client["Prisma client<br/>data access<br/>[prisma.ts]"]
  node_orchestration["SSH orchestrator<br/>deployment service<br/>[sshOrchestrator.ts]"]
  node_aws_service["AWS integration<br/>cloud service<br/>[awsService.ts]"]
end

subgraph group_data["Persistence"]
  node_database[("SaaS database<br/>Prisma-managed database<br/>[schema.prisma]")]
end

subgraph group_operations["Infrastructure"]
  node_compose["Container composition<br/>Docker Compose<br/>[docker-compose.yml]"]
  node_terraform["AWS provisioning<br/>Terraform<br/>[main.tf]"]
  node_ansible["Host automation<br/>Ansible<br/>[playbook.yml]"]
end

node_browser(("Browser user<br/>client"))
node_managed_hosts{{"AWS and managed servers<br/>external infrastructure"}}

node_browser -->|"loads"| node_frontend_entry
node_frontend_entry -->|"mounts"| node_app_shell
node_app_shell -->|"renders in"| node_layout
node_app_shell -->|"reads session"| node_auth_store
node_app_shell -->|"shows feedback"| node_toast_store
node_app_shell -->|"initiates actions"| node_api_client
node_api_client -->|"HTTPS API requests"| node_server
node_server -->|"applies"| node_request_controls
node_request_controls -->|"permits requests"| node_api_routes
node_api_routes -->|"dispatches"| node_controllers
node_controllers -->|"persists domain data"| node_prisma_client
node_prisma_client -->|"queries"| node_database
node_controllers -->|"triggers deployments"| node_orchestration
node_controllers -->|"uses cloud capabilities"| node_aws_service
node_orchestration -->|"SSH execution"| node_managed_hosts
node_aws_service -->|"AWS API"| node_managed_hosts
node_compose -.->|"runs backend image"| node_server
node_terraform -.->|"provisions"| node_managed_hosts
node_ansible -.->|"configures"| node_managed_hosts

click node_frontend_entry "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/main.tsx"
click node_app_shell "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/App.tsx"
click node_layout "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/components/layout/AppLayout.tsx"
click node_api_client "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/services/api.ts"
click node_auth_store "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/store/authStore.ts"
click node_toast_store "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/store/toastStore.ts"
click node_server "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/server.ts"
click node_api_routes "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/routes/authRoutes.ts"
click node_controllers "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/controllers/authController.ts"
click node_request_controls "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/middleware/authMiddleware.ts"
click node_prisma_client "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/prisma.ts"
click node_orchestration "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/services/sshOrchestrator.ts"
click node_aws_service "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/services/awsService.ts"
click node_database "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/prisma/schema.prisma"
click node_compose "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/docker-compose.yml"
click node_terraform "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/infrastructure/terraform/main.tf"
click node_ansible "https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/infrastructure/ansible/playbook.yml"

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_frontend_entry,node_app_shell,node_layout,node_api_client,node_auth_store,node_toast_store toneBlue
class node_server,node_api_routes,node_controllers,node_request_controls,node_prisma_client,node_orchestration,node_aws_service toneAmber
class node_database toneMint
class node_compose,node_terraform,node_ansible toneRose
class node_browser,node_managed_hosts toneNeutral
```

## Components

### React SPA

- [Vite entry](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/main.tsx): React entrypoint · `DevOpsHub/frontend/src/main.tsx`
- [App shell and pages](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/App.tsx): React UI · Selects feature pages within persistent navigation. · `DevOpsHub/frontend/src/App.tsx`
- [Persistent layout](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/components/layout/AppLayout.tsx): React layout · `DevOpsHub/frontend/src/components/layout/AppLayout.tsx`
- [API client](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/services/api.ts): HTTP client · Carries authenticated browser requests to the API. · `DevOpsHub/frontend/src/services/api.ts`
- [Auth state](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/store/authStore.ts): client store · `DevOpsHub/frontend/src/store/authStore.ts`
- [Request feedback](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/frontend/src/store/toastStore.ts): client store · `DevOpsHub/frontend/src/store/toastStore.ts`

### Backend API

- [HTTP server](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/server.ts): Node.js entrypoint · `DevOpsHub/backend/src/server.ts`
- [Auth and project routes](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/routes/authRoutes.ts): route modules · `DevOpsHub/backend/src/routes/authRoutes.ts`
- [Auth and project controllers](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/controllers/authController.ts): controllers · `DevOpsHub/backend/src/controllers/authController.ts`
- [Auth and error controls](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/middleware/authMiddleware.ts): middleware · Protects operations and applies rate/error handling. · `DevOpsHub/backend/src/middleware/authMiddleware.ts`
- [Prisma client](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/prisma.ts): data access · `DevOpsHub/backend/src/prisma.ts`
- [SSH orchestrator](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/services/sshOrchestrator.ts): deployment service · `DevOpsHub/backend/src/services/sshOrchestrator.ts`
- [AWS integration](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/src/services/awsService.ts): cloud service · `DevOpsHub/backend/src/services/awsService.ts`

### Persistence

- [SaaS database](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/backend/prisma/schema.prisma): Prisma-managed database · Schema includes tenant, OTP, and deployment-stage evolution. · `DevOpsHub/backend/prisma/schema.prisma`

### Infrastructure

- [Container composition](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/docker-compose.yml): Docker Compose · `DevOpsHub/docker-compose.yml`
- [AWS provisioning](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/infrastructure/terraform/main.tf): Terraform · `DevOpsHub/infrastructure/terraform/main.tf`
- [Host automation](https://github.com/hardikkhyal/self-host/blob/main/DevOpsHub/infrastructure/ansible/playbook.yml): Ansible · `DevOpsHub/infrastructure/ansible/playbook.yml`

### Other components

- **Browser user**: client
- **AWS and managed servers**: external infrastructure

## Connections

- Browser user → Vite entry: loads
- Vite entry → App shell and pages: mounts
- App shell and pages → Persistent layout: renders in
- App shell and pages → Auth state: reads session
- App shell and pages → Request feedback: shows feedback
- App shell and pages → API client: initiates actions
- API client → HTTP server: HTTPS API requests
- HTTP server → Auth and error controls: applies
- Auth and error controls → Auth and project routes: permits requests
- Auth and project routes → Auth and project controllers: dispatches
- Auth and project controllers → Prisma client: persists domain data
- Prisma client → SaaS database: queries
- Auth and project controllers → SSH orchestrator: triggers deployments
- Auth and project controllers → AWS integration: uses cloud capabilities
- SSH orchestrator → AWS and managed servers: SSH execution
- AWS integration → AWS and managed servers: AWS API
- Container composition → HTTP server: runs backend image
- AWS provisioning → AWS and managed servers: provisions
- Host automation → AWS and managed servers: configures
