# edithkaren/ticket-raising-system architecture

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

- Interactive diagram: https://gitdiagram.com/edithkaren/ticket-raising-system
- Repository: https://github.com/edithkaren/ticket-raising-system

## Overview

#### Purpose and Entry Points
This repository implements a Go/Gin REST API for authenticated, owner-scoped support-ticket management. The backend process starts in `main.go`; HTTP route handlers are in `handlers/handlers.go`. `Dockerfile` packages the service for port-8080 deployment.

A separate Vite/React frontend also exists, rooted at `src/main.tsx` and `src/App.tsx`, with `server.ts` potentially serving as a Node-side integration entry point.

#### HTTP API and Routing Layer
`main.go` initializes the Gin server, database, handlers, and route groups. `handlers/handlers.go` implements:
- public health and authentication endpoints;
- protected ticket creation, listing, retrieval, and status-update endpoints;
- request parsing, response formatting, and business-rule enforcement.

The API boundary is JSON over HTTP; protected routes depend on authenticated identity supplied by middleware.

#### Authentication and Authorization
`middleware/auth.go` validates JWT bearer tokens and places authenticated user context into Gin requests. `handlers/handlers.go` uses that context to associate created tickets with a user and restrict reads/updates to the ticket owner.

Registration and login reside in `handlers/handlers.go`; password credentials are bcrypt-hashed and JWTs are signed using `JWT_SECRET`. This is the primary security boundary between public authentication routes and `/tickets` operations.

#### Domain Model and Workflow Rules
`models/models.go` defines the core persisted/request domain types, notably users and tickets. Tickets have an ownership relationship to users and a constrained lifecycle: `open` → `in_progress` → `closed`; closed tickets cannot be reopened.

The status transition rule is enforced at the handler/domain boundary in `handlers/handlers.go`, before persistence updates. Ownership checks likewise occur before exposing or mutating ticket records.

#### Persistence Layer
`db/db.go` owns SQLite initialization and database access setup. It uses the pure-Go `modernc.org/sqlite` driver, avoiding CGO and any external database service.

Control flow is: application startup initializes SQLite schema/access through `db/db.go`; handlers in `handlers/handlers.go` query or mutate users and tickets; model structures in `models/models.go` carry data between HTTP and persistence concerns.

#### Runtime and Deployment
The primary runtime is Go 1.21+ with Gin, SQLite, JWT, and bcrypt dependencies defined by `go.mod`. Environment-controlled operational inputs are `PORT` (default 8080) and `JWT_SECRET` (default `secret`).

`Dockerfile` is the deployable backend packaging boundary. SQLite persistence is local to the runtime filesystem, so durable production storage requires an appropriate mounted volume or equivalent filesystem strategy.

#### Frontend Surface
The repository includes a TypeScript React/Vite client: `src/main.tsx` bootstraps the app, `src/App.tsx` contains the main UI, and `src/types.ts` defines client-side shared shapes. It is operationally distinct from the Go API and communicates across the same HTTP/JSON API boundary.

Main entry points: [`handlers/handlers.go`](https://github.com/edithkaren/ticket-raising-system/blob/main/handlers/handlers.go) (Handlers), [`main.go`](https://github.com/edithkaren/ticket-raising-system/blob/main/main.go) (API bootstrap), [`src/App.tsx`](https://github.com/edithkaren/ticket-raising-system/blob/main/src/App.tsx) (Ticket UI), [`db/db.go`](https://github.com/edithkaren/ticket-raising-system/blob/main/db/db.go) (SQLite access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Go API"]
  node_docker["Docker image<br/>deployment"]
  node_main{{"API bootstrap<br/>Go entry point<br/>[main.go]"}}
  node_routes["Gin routes<br/>HTTP routing<br/>[main.go]"]
  node_handlers["Handlers<br/>request and policy layer<br/>[handlers.go]"]
  node_auth["JWT middleware<br/>authentication<br/>[auth.go]"]
  node_models["Users and tickets<br/>domain models<br/>[models.go]"]
  node_workflow["Ticket lifecycle<br/>business rule<br/>[handlers.go]"]
  node_database[("SQLite access<br/>persistence layer<br/>[db.go]")]
  node_sqlite[("Local SQLite data<br/>embedded database")]
  node_runtime["Go runtime config<br/>operational inputs<br/>[go.mod]"]
end

subgraph group_frontend["React Client"]
  node_client_bootstrap{{"Client bootstrap<br/>React entry point<br/>[main.tsx]"}}
  node_app["Ticket UI<br/>React application<br/>[App.tsx]"]
  node_client_types["Client types<br/>TypeScript models<br/>[types.ts]"]
  node_node_entry["Node integration<br/>Node entry point<br/>[server.ts]"]
end

node_http_api(("HTTP/JSON API<br/>service boundary"))

node_docker -->|"runs"| node_main
node_runtime -.->|"configures"| node_main
node_main -->|"initializes"| node_database
node_main -->|"registers"| node_routes
node_routes -->|"dispatches"| node_handlers
node_routes -->|"protects ticket routes"| node_auth
node_auth -->|"supplies identity"| node_handlers
node_handlers -->|"enforces"| node_workflow
node_handlers -->|"uses"| node_models
node_handlers -->|"queries and mutates"| node_database
node_database -->|"stores locally"| node_sqlite
node_http_api -->|"requests"| node_routes
node_client_bootstrap -->|"renders"| node_app
node_app -->|"uses"| node_client_types
node_app -->|"HTTP/JSON"| node_http_api
node_node_entry -.->|"integrates"| node_app

click node_docker "https://github.com/edithkaren/ticket-raising-system/blob/main/Dockerfile"
click node_main "https://github.com/edithkaren/ticket-raising-system/blob/main/main.go"
click node_routes "https://github.com/edithkaren/ticket-raising-system/blob/main/main.go"
click node_handlers "https://github.com/edithkaren/ticket-raising-system/blob/main/handlers/handlers.go"
click node_auth "https://github.com/edithkaren/ticket-raising-system/blob/main/middleware/auth.go"
click node_models "https://github.com/edithkaren/ticket-raising-system/blob/main/models/models.go"
click node_workflow "https://github.com/edithkaren/ticket-raising-system/blob/main/handlers/handlers.go"
click node_database "https://github.com/edithkaren/ticket-raising-system/blob/main/db/db.go"
click node_runtime "https://github.com/edithkaren/ticket-raising-system/blob/main/go.mod"
click node_client_bootstrap "https://github.com/edithkaren/ticket-raising-system/blob/main/src/main.tsx"
click node_app "https://github.com/edithkaren/ticket-raising-system/blob/main/src/App.tsx"
click node_client_types "https://github.com/edithkaren/ticket-raising-system/blob/main/src/types.ts"
click node_node_entry "https://github.com/edithkaren/ticket-raising-system/blob/main/server.ts"

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_docker,node_main,node_routes,node_handlers,node_auth,node_models,node_workflow,node_database,node_sqlite,node_runtime toneBlue
class node_client_bootstrap,node_app,node_client_types,node_node_entry toneAmber
class node_http_api toneNeutral
```

## Components

### Go API

Authenticated ticket-management backend.

- [Docker image](https://github.com/edithkaren/ticket-raising-system/blob/main/Dockerfile): deployment · Packages the backend for port 8080. · `Dockerfile`
- [API bootstrap](https://github.com/edithkaren/ticket-raising-system/blob/main/main.go): Go entry point · Initializes Gin, database, handlers, and routes. · `main.go`
- [Gin routes](https://github.com/edithkaren/ticket-raising-system/blob/main/main.go): HTTP routing · Public auth/health and protected ticket endpoints. · `main.go`
- [Handlers](https://github.com/edithkaren/ticket-raising-system/blob/main/handlers/handlers.go): request and policy layer · Parses requests, enforces ownership and ticket rules. · `handlers/handlers.go`
- [JWT middleware](https://github.com/edithkaren/ticket-raising-system/blob/main/middleware/auth.go): authentication · Validates bearer tokens and injects user context. · `middleware/auth.go`
- [Users and tickets](https://github.com/edithkaren/ticket-raising-system/blob/main/models/models.go): domain models · Defines persisted and request domain types. · `models/models.go`
- [Ticket lifecycle](https://github.com/edithkaren/ticket-raising-system/blob/main/handlers/handlers.go): business rule · Allows open → in_progress → closed; closed tickets stay closed. · `handlers/handlers.go`
- [SQLite access](https://github.com/edithkaren/ticket-raising-system/blob/main/db/db.go): persistence layer · Initializes schema and database access with modernc SQLite. · `db/db.go`
- **Local SQLite data**: embedded database · Durability depends on runtime filesystem storage.
- [Go runtime config](https://github.com/edithkaren/ticket-raising-system/blob/main/go.mod): operational inputs · Uses PORT and JWT_SECRET. · `go.mod`

### React Client

Operationally distinct Vite frontend.

- [Client bootstrap](https://github.com/edithkaren/ticket-raising-system/blob/main/src/main.tsx): React entry point · Bootstraps the Vite React application. · `src/main.tsx`
- [Ticket UI](https://github.com/edithkaren/ticket-raising-system/blob/main/src/App.tsx): React application · Main frontend user interface. · `src/App.tsx`
- [Client types](https://github.com/edithkaren/ticket-raising-system/blob/main/src/types.ts): TypeScript models · Shared client-side shapes. · `src/types.ts`
- [Node integration](https://github.com/edithkaren/ticket-raising-system/blob/main/server.ts): Node entry point · Potential Node-side integration entry. · `server.ts`

### Other components

- **HTTP/JSON API**: service boundary · Public and authenticated REST interface.

## Connections

- Docker image → API bootstrap: runs
- Go runtime config → API bootstrap: configures
- API bootstrap → SQLite access: initializes
- API bootstrap → Gin routes: registers
- Gin routes → Handlers: dispatches
- Gin routes → JWT middleware: protects ticket routes
- JWT middleware → Handlers: supplies identity
- Handlers → Ticket lifecycle: enforces
- Handlers → Users and tickets: uses
- Handlers → SQLite access: queries and mutates
- SQLite access → Local SQLite data: stores locally
- HTTP/JSON API → Gin routes: requests
- Client bootstrap → Ticket UI: renders
- Ticket UI → Client types: uses
- Ticket UI → HTTP/JSON API: HTTP/JSON
- Node integration → Ticket UI: integrates
