# tham-bahadur-pun/issue-tracker architecture

> Architecture diagram of the GitHub repository tham-bahadur-pun/issue-tracker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tham-bahadur-pun/issue-tracker
- Repository: https://github.com/tham-bahadur-pun/issue-tracker

## Overview

##### Main Components

a. Frontend Layer:
- Issue Management UI (IssueChart, IssueSummary, LatestIssue)
- Navigation Components (Navbar)
- Issue CRUD Components (IssueForm, IssueDetail)
- Shared Components (ErrorMessage, Spinner, Pagination)

b. Next.js App Router Layer:
- Pages (/, /issues, /issues/[id], /issues/new)
- API Routes (/api/issues, /api/auth, /api/users)
- Layout System (layout.tsx, loading states)

c. Authentication Layer:
- NextAuth.js integration
- Auth Provider & Options
- Protected Routes

d. Data Layer:
- Prisma ORM
- Database Schema (Issues, Users)
- Database Migrations

e. External Services:
- Sentry (Error Tracking)
- Authentication Providers

##### Relationships and Data Flow

- Client-side requests → API Routes
- API Routes → Prisma Client
- Prisma Client → Database
- Authentication flow through NextAuth.js
- Error tracking flow to Sentry

##### Technical Stack Highlights

- Next.js 13+
- TypeScript
- Prisma ORM
- NextAuth.js
- Tailwind CSS
- Sentry

##### Key Design Patterns

Highlight:
- Component composition pattern
- Repository pattern (Prisma)
- Provider pattern (Auth, Query Client)
- Route handlers pattern

Important Notes:
- Keep the authentication flow visible but not overwhelming
- Separation between client and server components
- How error handling and loading states are managed
- Relationship between issues and users as shown in the Prisma schema

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI[Client-Side Components]
        UI --> |Contains| IssueUI[Issue Management UI]
        UI --> |Contains| NavUI[Navigation Components]
        UI --> |Contains| SharedUI[Shared Components]
        
        IssueUI --> |Components| IC[IssueChart]:::file
        IssueUI --> |Components| IS[IssueSummary]:::file
        IssueUI --> |Components| LI[LatestIssue]:::file
        IssueUI --> |Components| IF[IssueForm]:::file
        IssueUI --> |Components| ID[IssueDetail]:::file
        
        NavUI --> |Components| NB[Navbar]:::file
        NavUI --> |Components| CL["Custom Link"]:::file
        
        SharedUI --> |Components| EM[ErrorMessage]:::file
        SharedUI --> |Components| SP[Spinner]:::file
        SharedUI --> |Components| PG[Pagination]:::file
        SharedUI --> |Components| SB[StatusBadge]:::file
    end
    
    subgraph AppRouter
        AR[Next.js App Router]
        AR --> |Routes| Pages
        AR --> |API| APIRoutes
        AR --> |System| LayoutSystem
        
        Pages --> Dashboard:::file
        Pages --> IssuesPage
        Pages --> IssueDetail
        Pages --> NewIssue
        
        APIRoutes --> IssuesAPI:::file
        APIRoutes --> UsersAPI:::file
        APIRoutes --> AuthAPI:::file
        
        LayoutSystem --> RootLayout:::file
        LayoutSystem --> GlobalError:::file
        LayoutSystem --> LoadingStates:::file
    end
    
    subgraph Auth
        AuthLayer[Authentication Layer]
        AuthLayer --> AuthProvider:::file
        AuthLayer --> AuthOptions:::file
        AuthLayer --> NextAuthConfig:::file
    end
    
    subgraph Data
        DataLayer[Data Layer]
        DataLayer --> PrismaClient:::file
        DataLayer --> Schema:::file
        DataLayer --> Migrations:::directory
    end
    
    subgraph External
        ExtServices[External Services]
        ExtServices --> SentryClient:::file
        ExtServices --> SentryServer:::file
        ExtServices --> SentryEdge:::file
    end
    
    UI --> AR
    AR --> AuthLayer
    AuthLayer --> DataLayer
    AR --> DataLayer
    AR --> ExtServices

    %% Click Events
    click IC "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/IssueChart.tsx"
    click IS "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/IssueSummary.tsx"
    click LI "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/LatestIssue.tsx"
    click IF "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/issues/_components/IssueForm.tsx"
    click ID "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/issues/[id]/IssueDetail.tsx"
    click NB "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/Navbar.tsx"
    click CL "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/components/Link.tsx"
    click EM "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/components/ErrorMessage.tsx"
    click SP "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/components/Spinner.tsx"
    click PG "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/components/Pagination.tsx"
    click SB "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/components/IssueStatusBadge.tsx"
    click Dashboard "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/page.tsx"
    click IssuesAPI "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/api/issues/route.tsx"
    click UsersAPI "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/api/users/route.ts"
    click AuthAPI "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/api/auth/[...nextauth]/route.ts"
    click RootLayout "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/layout.tsx"
    click GlobalError "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/global-error.jsx"
    click LoadingStates "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/issues/loading.tsx"
    click AuthProvider "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/auth/AuthProvider.tsx"
    click AuthOptions "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/auth/AuthOptions.ts"
    click NextAuthConfig "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/app/api/auth/[...nextauth]/route.ts"
    click PrismaClient "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/prisma/client.ts"
    click Schema "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/prisma/schema.prisma"
    click Migrations "https://github.com/Tham-Bahadur-Pun/issue-tracker/tree/master/prisma/migrations/"
    click SentryClient "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/sentry.client.config.ts"
    click SentryServer "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/sentry.server.config.ts"
    click SentryEdge "https://github.com/Tham-Bahadur-Pun/issue-tracker/blob/master/sentry.edge.config.ts"

    %% Styling
    classDef file fill:#f9f,stroke:#333,stroke-width:2px
    classDef directory fill:#ff9,stroke:#333,stroke-width:2px
    
    %% Legend
    subgraph Legend
        L1[Frontend Components]
        L2[App Router Components]
        L3[Authentication Components]
        L4[Data Layer Components]
        L5[External Services]
        L6[File]:::file
        L7[Directory]:::directory
    end
```
