# ruangustavo/ifrncalc architecture

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

- Interactive diagram: https://gitdiagram.com/ruangustavo/ifrncalc
- Repository: https://github.com/ruangustavo/ifrncalc

## Overview

##### Main Components

a. Client-Side Layer:
- Next.js frontend components structure
- Main pages (/dashboard, root page)
- UI components library
- State management using the store

b. Authentication Layer:
- NextAuth.js integration
- SUAP OAuth2 connection
- Session management

c. Server-Side Layer:
- API routes
- Server actions
- Grade calculation logic

d. External Services:
- SUAP API integration

**[Client Layer]**
- ↑↓
**[Server Layer]**
- ↑↓
**[External Services]**

##### Detailed Component Breakdown

Client Layer:
- Main pages: /(root), /dashboard
- Components structure:
- UI components (from /components/ui)
- Dashboard components
- Theme components
- Zustand store (grades.ts)

Server Layer:
- API routes (/api/auth/[...nextauth])
- Server actions (get-grades.ts)
- Grade calculation utilities

Authentication Flow:
- NextAuth.js configuration
- SUAP OAuth2 flow
- Session management

##### Key Relationships to Highlight

- How the authentication flow connects the client to SUAP
- Demonstrate data flow from SUAP API through server actions to the client
- State management flow with the grades store
- Theme provider context flow

##### Additional Elements

- Environment configuration section
- Build/deployment flow
- Error handling paths
- Caching mechanisms if any

##### Specific Architectural Patterns to Highlight

- Next.js App Router structure
- Server Components vs Client Components
- OAuth2 flow with NextAuth.js
- State management with Zustand

- Component types
- Flow direction conventions
- Any special symbols used

This will help other developers understand the system architecture at a glance while providing enough detail for implementation and maintenance.

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2563eb',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#1d4ed8',
    'lineColor': '#64748b',
    'secondaryColor': '#4ade80',
    'tertiaryColor': '#f97316'
  }
}}%%

flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        Pages["Pages"]
        Components["Components"]
        Store["State Management"]
        ThemeSystem["Theme System"]
        
        subgraph Pages
            Dashboard["Dashboard Page"]:::client
            RootPage["Root Page"]:::client
        end
        
        subgraph Components
            UI["UI Components"]:::client
            DashboardComp["Dashboard Components"]:::client
            AuthComp["Auth Components"]:::client
        end
        
        Store --> Dashboard
        ThemeSystem --> Pages
        Components --> Pages
    end
    
    subgraph Server["Server Layer"]
        direction TB
        API["API Routes"]
        ServerActions["Server Actions"]
        Utils["Utilities"]
        
        subgraph API
            AuthAPI["Auth API"]:::server
        end
        
        subgraph ServerActions
            GetGrades["Get Grades Action"]:::server
        end
        
        subgraph Utils
            GradeCalc["Grade Calculation"]:::server
            SiteConfig["Site Configuration"]:::server
        end
    end
    
    subgraph Auth["Authentication Layer"]
        direction TB
        NextAuth["NextAuth.js"]:::auth
        Session["Session Management"]:::auth
    end
    
    subgraph External["External Services"]
        SUAP["SUAP API"]:::external
    end
    
    %% Relationships
    Client <--> Server
    Auth <--> Server
    Server <--> External
    
    %% Click Events
    click UI "https://github.com/ruangustavo/ifrncalc/tree/master/src/components/ui/"
    click DashboardComp "https://github.com/ruangustavo/ifrncalc/tree/master/src/app/dashboard/_components/"
    click AuthAPI "https://github.com/ruangustavo/ifrncalc/blob/master/src/app/api/auth/[...nextauth]/route.ts"
    click Store "https://github.com/ruangustavo/ifrncalc/blob/master/src/store/grades.ts"
    click ThemeSystem "https://github.com/ruangustavo/ifrncalc/blob/master/src/components/theme-provider.tsx"
    click GetGrades "https://github.com/ruangustavo/ifrncalc/blob/master/src/actions/get-grades.ts"
    click GradeCalc "https://github.com/ruangustavo/ifrncalc/blob/master/src/utils/grade-calculation.ts"
    click Dashboard "https://github.com/ruangustavo/ifrncalc/blob/master/src/app/dashboard/page.tsx"
    click AuthComp "https://github.com/ruangustavo/ifrncalc/blob/master/src/app/(app)/_components/sign-in-button.tsx"
    click SiteConfig "https://github.com/ruangustavo/ifrncalc/blob/master/src/config/site.ts"

    %% Styles
    classDef client fill:#2563eb,color:#fff,stroke:#1d4ed8
    classDef server fill:#4ade80,color:#fff,stroke:#22c55e
    classDef auth fill:#f97316,color:#fff,stroke:#ea580c
    classDef external fill:#a855f7,color:#fff,stroke:#9333ea
    
    %% Legend
    subgraph Legend
        direction TB
        ClientLegend["Client Component"]:::client
        ServerLegend["Server Component"]:::server
        AuthLegend["Auth Component"]:::auth
        ExternalLegend["External Service"]:::external
    end
```
