# jana19-dev/pennywise architecture

> Architecture diagram of the GitHub repository jana19-dev/pennywise, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jana19-dev/pennywise
- Repository: https://github.com/jana19-dev/pennywise

## Overview

##### High-Level Architecture Components

A. Frontend Layer
- SvelteKit Application
- Authentication Views (login/logout)
- Protected Routes (accounts, transactions, reports)
- UI Components
- GraphQL Client

B. API Layer
- GraphQL Server
- Authentication/Authorization Middleware
- Resolvers for different entities

C. Database Layer
- Prisma ORM
- Database (implied from prisma.schema)

##### Key Relationships to Highlight

- Frontend components and GraphQL client
- GraphQL client and GraphQL server
- GraphQL server and Prisma ORM
- Authentication flow between layers

##### Detailed Component Breakdown

- Components/
- Application Components (accounts, transactions, etc.)
- UI Components (buttons, forms, dialogs)
- Select Inputs

- GraphQL/
- Client Queries/Mutations
- Server Resolvers
- Type Definitions

- Entities
- Accounts
- AccountTypes
- Categories
- Payees
- Transactions

##### Data Flow Representation

- User interactions → Frontend Components
- Frontend → GraphQL Client
- GraphQL Client → GraphQL Server
- GraphQL Server → Database
- Response flow back to user

##### Technical Stack Callouts

Technologies:
- SvelteKit
- GraphQL
- Prisma
- TailwindCSS
- Firebase (for authentication)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        UI[UI Components]
        AuthViews[Authentication Views]
        ProtectedRoutes[Protected Routes]
        GQLClient[GraphQL Client]
        Cache[Cache Management]
        
        subgraph AppComponents
            Accounts[Account Management]
            Transactions[Transaction Management]
            Categories[Category Management]
            Payees[Payee Management]
            Reports[Report Generation]
            Forms[Form Components]
            Nav[Sidebar Navigation]
        end
        
        UI --> AppComponents
        AuthViews --> ProtectedRoutes
        ProtectedRoutes --> AppComponents
        AppComponents --> GQLClient
        GQLClient --> Cache
    end
    
    subgraph APILayer
        GQLServer[GraphQL Server]
        AuthMiddleware[Authentication Middleware]
        AuthSystem[Authorization System]
        Resolvers[GraphQL Resolvers]
        TypeDefs[GraphQL Type Definitions]
        
        GQLServer --> AuthMiddleware
        AuthMiddleware --> AuthSystem
        GQLServer --> Resolvers
        Resolvers --> TypeDefs
    end
    
    subgraph Database
        PrismaORM[Prisma ORM]
        DBSchema[Database Schema]
        
        PrismaORM --> DBSchema
    end
    
    GQLClient --> GQLServer
    Resolvers --> PrismaORM
    
    %% Component Mappings
    click UI "https://github.com/jana19-dev/pennywise/tree/main/src/lib/components/ui"
    click AuthViews "https://github.com/jana19-dev/pennywise/tree/main/src/routes/login"
    click ProtectedRoutes "https://github.com/jana19-dev/pennywise/tree/main/src/routes/(authenticated)"
    click GQLClient "https://github.com/jana19-dev/pennywise/tree/main/src/lib/graphql/client"
    click GQLServer "https://github.com/jana19-dev/pennywise/tree/main/src/routes/api/graphql"
    click AuthMiddleware "https://github.com/jana19-dev/pennywise/blob/main/src/lib/utils/server/authentication.js"
    click Resolvers "https://github.com/jana19-dev/pennywise/tree/main/src/lib/graphql/server/resolvers"
    click DBSchema "https://github.com/jana19-dev/pennywise/blob/main/schema.prisma"
    click Accounts "https://github.com/jana19-dev/pennywise/tree/main/src/lib/components/application/account"
    click Transactions "https://github.com/jana19-dev/pennywise/tree/main/src/lib/components/application/transaction"
    click Categories "https://github.com/jana19-dev/pennywise/tree/main/src/lib/components/application/category"
    click Payees "https://github.com/jana19-dev/pennywise/tree/main/src/lib/components/application/payee"
    click Reports "https://github.com/jana19-dev/pennywise/tree/main/src/lib/components/application/report"
    click TypeDefs "https://github.com/jana19-dev/pennywise/tree/main/src/lib/graphql/server/typeDefs"
    click AuthSystem "https://github.com/jana19-dev/pennywise/blob/main/src/lib/utils/server/authorization.js"
    click Cache "https://github.com/jana19-dev/pennywise/blob/main/src/lib/utils/client/cacheInvalidation.js"
    click Nav "https://github.com/jana19-dev/pennywise/tree/main/src/lib/components/sidebar"
    click Forms "https://github.com/jana19-dev/pennywise/tree/main/src/lib/components/select"
    
    classDef frontend fill:#e1f5fe,stroke:#01579b
    classDef api fill:#e8f5e9,stroke:#1b5e20
    classDef database fill:#fff3e0,stroke:#e65100
    
    class UI,AuthViews,ProtectedRoutes,GQLClient,Cache,Accounts,Transactions,Categories,Payees,Reports,Forms,Nav,AppComponents frontend
    class GQLServer,AuthMiddleware,AuthSystem,Resolvers,TypeDefs api
    class PrismaORM,DBSchema database
```
