# c-wenlong/ticket-master architecture

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

- Interactive diagram: https://gitdiagram.com/c-wenlong/ticket-master
- Repository: https://github.com/c-wenlong/ticket-master

## Overview

##### Project Type and Purpose
- This is a full-stack ticket management application built with Streamlit for the frontend. Its goal is to enable users to manage tickets via a Kanban board, overview screens, and interactive forms.
- The README clearly explains features such as user authentication, ticket creation (both manual and AI-assisted), and role-based access control. Meanwhile, the file tree shows a split between frontend and backend code, indicating a layered architecture.

##### File Structure for Main Components
- Frontend:
- Located in the "frontend" directory.
- Contains pages (e.g., Home, Tickets Overview, Kanban Board) that define the user interface, along with components (e.g., KanbanCard, TicketForm, KanbanBoard, TicketTable), entities, and services.
- Uses Streamlit to manage state and render UI components.
- Backend:
- Exists under the "backend" directory and is further divided into several parts:
o Analytics:
▪ Found under "backend/analytics". It uses a Node/TypeScript stack (e.g., package.json, rspack.config.cjs, and tsconfig.json).
▪ Contains configuration, database connectors, middleware, handler logic, and schema definitions. This likely handles reporting, statistics, or additional data processing related to ticketing insights.
o Ticket Service:
▪ Found under "backend/src/ticket". This section contains several directories each having a lambda_function.py, indicating discrete Python functions for ticket operations (create, find_similar, gen, list, search, update).
▪ This design suggests a microservice or serverless-like approach for handling ticket-specific operations.
- Documentation:
- The "docs" folder includes developer documentation with architecture and entity details which can be referenced for additional clarity.

##### Relationships and Interactions
- Frontend ↔ Backend:
- The frontend sends API requests to backend services. This likely involves two separate API endpoints – one for analytics and one for ticket operations.
- Within the Backend:
- The analytics module is a Node-based service that interacts with the database (as seen in “src/db”) and uses middleware for error handling and schema validation.
- The ticket operations are managed by discrete Python lambda functions, each handling a specific endpoint or functionality (e.g., creation, update). They might be exposed via an API gateway so that the frontend can call them.
- Shared Database:
- Both analytics and ticket management modules interact with database files in their respective “db” directories. They may use consistent data models as hinted by the “schema” directories.

##### Architectural Patterns and Technologies
- Separation of Concerns: The project clearly splits UI (frontend) from business logic (backend). Within the backend, analytics and ticket operations are in separate modules or microservices.
- Microservices/Serverless Pattern: The ticket functionality is built using individual lambda functions, indicating a design that favors separation of functionalities into discrete services.
- Middleware & Schema Validation: Both analytics and core backend components use middleware and defined schemas for data validation and error handling.
- Technology Stack:
- Frontend: Python, Streamlit for UI, with components and state management.
- Backend Analytics: Node.js/TypeScript, Docker for containerization (Dockerfile in analytics subfolder), and rspack for bundling.
- Backend Ticket Service: Python functions likely deployed in a serverless manner (each directory with its own lambda_function.py).

- Following elements:
▪ “Backend - Analytics Service” (Node.js/TypeScript) with subcomponents: config, DB layer, middleware, handlers, and schemas.
▪ “Backend - Ticket Service” (Python Lambda functions) with subcomponents representing each lambda (create, find_similar, gen, list, search, update).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Streamlit)"
        FE["Streamlit UI"]:::frontend
        FE_Pages["Pages: Home, Tickets Overview, Kanban Board"]:::frontend
        FE_Components["Components: KanbanCard, TicketForm, KanbanBoard, TicketTable"]:::frontend
        FE_Services["Services: analytics, ticket, etc."]:::frontend
    end

    %% API Gateway
    subgraph "API Gateway"
        API_GW["API Gateway"]:::api
    end

    %% Backend Layer
    subgraph "Backend"
        subgraph "Analytics Service (Node.js/TypeScript)"
            Analytics_Config["Configuration & Setup"]:::backend
            Analytics_DB["Database Layer"]:::backend
            Analytics_MW["Middleware & Handlers"]:::backend
            Analytics_Schemas["Schemas"]:::backend
        end
        subgraph "Ticket Service (Python Lambda Functions)"
            Ticket_Create["Lambda: Create"]:::backend
            Ticket_Find["Lambda: Find Similar"]:::backend
            Ticket_Gen["Lambda: Gen"]:::backend
            Ticket_List["Lambda: List"]:::backend
            Ticket_Search["Lambda: Search"]:::backend
            Ticket_Update["Lambda: Update"]:::backend
        end
    end

    %% Shared Database and Documentation
    Database["Database"]:::db
    Documentation["Documentation"]:::service

    %% Connections
    FE -->|"API_call"| API_GW
    FE_Pages -->|"user_action"| FE
    FE_Components -->|"state_update"| FE
    FE_Services -->|"service_call"| FE

    API_GW -->|"forward"| Analytics_Config
    API_GW -->|"forward"| Ticket_Create
    API_GW -->|"forward"| Ticket_Find
    API_GW -->|"forward"| Ticket_Gen
    API_GW -->|"forward"| Ticket_List
    API_GW -->|"forward"| Ticket_Search
    API_GW -->|"forward"| Ticket_Update

    Analytics_Config -->|"connects"| Analytics_DB
    Analytics_MW -->|"validates"| Analytics_Config
    Analytics_Schemas -->|"defines"| Analytics_DB
    Analytics_DB -->|"query"| Database

    Ticket_Create -->|"db_query"| Database
    Ticket_Find -->|"db_query"| Database
    Ticket_Gen -->|"db_query"| Database
    Ticket_List -->|"db_query"| Database
    Ticket_Search -->|"db_query"| Database
    Ticket_Update -->|"db_query"| Database

    FE -->|"ref_docs"| Documentation

    %% Click Events
    click FE "https://github.com/c-wenlong/ticket-master/tree/main/frontend/src"
    click FE_Pages "https://github.com/c-wenlong/ticket-master/tree/main/frontend/src/pages"
    click FE_Components "https://github.com/c-wenlong/ticket-master/tree/main/frontend/src/components"
    click FE_Services "https://github.com/c-wenlong/ticket-master/tree/main/frontend/src/services"
    click Analytics_Config "https://github.com/c-wenlong/ticket-master/tree/main/backend/analytics/src"
    click Analytics_DB "https://github.com/c-wenlong/ticket-master/tree/main/backend/analytics/src/db"
    click Analytics_MW "https://github.com/c-wenlong/ticket-master/tree/main/backend/analytics/src/middleware"
    click Analytics_Schemas "https://github.com/c-wenlong/ticket-master/tree/main/backend/analytics/src/schema"
    click Ticket_Create "https://github.com/c-wenlong/ticket-master/tree/main/backend/src/ticket/create"
    click Ticket_Find "https://github.com/c-wenlong/ticket-master/tree/main/backend/src/ticket/find_similar"
    click Ticket_Gen "https://github.com/c-wenlong/ticket-master/tree/main/backend/src/ticket/gen"
    click Ticket_List "https://github.com/c-wenlong/ticket-master/tree/main/backend/src/ticket/list"
    click Ticket_Search "https://github.com/c-wenlong/ticket-master/tree/main/backend/src/ticket/search"
    click Ticket_Update "https://github.com/c-wenlong/ticket-master/tree/main/backend/src/ticket/update"
    click Documentation "https://github.com/c-wenlong/ticket-master/tree/main/docs"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1f78b4,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef api fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef db fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef service fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
```
