# entur/ninkasi architecture

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

- Interactive diagram: https://gitdiagram.com/entur/ninkasi
- Repository: https://github.com/entur/ninkasi

## Overview

##### Main Components

a) Frontend Layer:
- React Application (evident from the src structure)
- Key UI Components:
- Providers Management
- Organization Management
- User Management
- Geocoder Interface
- Event Management

b) Authentication Layer:
- Keycloak Integration
- JWT Token handling

c) External Services Layer (Multiple REST APIs):
- Providers Service
- Organizations Service
- Timetable Admin Service
- Admin Service
- Geocoder Admin Service
- Events Service

##### Architectural Patterns to Highlight

a) Redux Pattern (visible from reducers and actions folders):
- Actions
- Reducers
- Store
- State Management Flow

b) Component-Based Architecture:
- Screens
- Modals
- Common Components

**[Client Layer] → [Authentication Layer] → [Services Layer]**

##### Specific Elements

a) Client Layer:
- Main React components
- Redux store
- Configuration management (ConfigContext)
- Routing structure

b) Authentication Layer:
- Keycloak integration
- JWT token flow
- Authentication endpoints

c) Services Layer:
- All external REST APIs
- Base URLs for each service
- Data flow directions

##### Important Flows to Highlight

- User authentication flow
- Data pipeline management flow
- Event monitoring flow
- Organization/User management flow

##### Additional Details

- Firebase hosting configuration (noted from .firebaserc)
- Environment-specific configurations (dev/prod/test)
- Micro-frontend architecture aspects (seen in MicroFrontendFetchStatus component)

##### Technical Stack Indicators

- React
- Redux
- Firebase
- Keycloak
- SASS (for styling)
- Node.js requirements (v18+)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        App["Main Application"]
        click App "https://github.com/entur/ninkasi/blob/master/src/app/App.js"
        
        subgraph UI["UI Components"]
            Header["Header Component"]
            click Header "https://github.com/entur/ninkasi/blob/master/src/app/components/Header.js"
            Menu["Navigation Menu"]
            click Menu "https://github.com/entur/ninkasi/blob/master/src/app/components/Menu.js"
            CommonComp["Common Components"]
            click CommonComp "https://github.com/entur/ninkasi/tree/master/src/screens/common/"
            Modals["Modal System"]
            click Modals "https://github.com/entur/ninkasi/tree/master/src/modals/"
        end

        subgraph State["State Management"]
            Store["Redux Store"]
            click Store "https://github.com/entur/ninkasi/blob/master/src/store/store.js"
            Actions["Actions"]
            click Actions "https://github.com/entur/ninkasi/tree/master/src/actions/"
            Reducers["Reducers"]
            click Reducers "https://github.com/entur/ninkasi/tree/master/src/reducers/"
            UserContext["User Context"]
            click UserContext "https://github.com/entur/ninkasi/blob/master/src/actions/UserContextActions.js"
        end

        subgraph Config["Configuration"]
            ConfigContext["Configuration Management"]
            click ConfigContext "https://github.com/entur/ninkasi/blob/master/src/config/ConfigContext.js"
            EnvConfig["Environment Configurations"]
            click EnvConfig "https://github.com/entur/ninkasi/tree/master/src/config/environments/"
        end

        subgraph Screens["Main Screens"]
            Providers["Providers Management"]
            click Providers "https://github.com/entur/ninkasi/tree/master/src/screens/providers/"
            Geocoder["Geocoder Interface"]
            click Geocoder "https://github.com/entur/ninkasi/tree/master/src/screens/geocoder/"
            OrgView["Organization Management"]
            click OrgView "https://github.com/entur/ninkasi/blob/master/src/screens/providers/components/organizationView/OrganizationView.js"
            UserView["User Management"]
            click UserView "https://github.com/entur/ninkasi/blob/master/src/screens/providers/components/userView/UserView.js"
            
            subgraph EventMgmt["Event Management"]
                EventFilters["Event Filters"]
                click EventFilters "https://github.com/entur/ninkasi/blob/master/src/modals/EventFilterActionsPopover.js"
                EventContent["Event Content"]
                click EventContent "https://github.com/entur/ninkasi/blob/master/src/screens/providers/components/EventExpandableContent.js"
            end
            
            subgraph OrgFeatures["Organization Features"]
                OrgRegister["Organization Register"]
                click OrgRegister "https://github.com/entur/ninkasi/blob/master/src/screens/providers/components/OrganizationRegister.js"
                OrgActions["Organization Actions"]
                click OrgActions "https://github.com/entur/ninkasi/blob/master/src/actions/OrganizationRegisterActions.js"
            end
        end

        subgraph Styling
            MainStyles["Main Styles"]
            click MainStyles "https://github.com/entur/ninkasi/blob/master/src/sass/main.scss"
            CompStyles["Component Styles"]
            click CompStyles "https://github.com/entur/ninkasi/tree/master/src/sass/components/"
        end
    end

    subgraph Auth["Authentication Layer"]
        Keycloak["Keycloak Integration"]
        JWTHandler["JWT Token Handler"]
    end

    subgraph Services["External Services"]
        ProvidersAPI["Providers Service"]
        OrgsAPI["Organizations Service"]
        TimetableAPI["Timetable Admin Service"]
        MapAPI["Map Admin Service"]
        GeocoderAPI["Geocoder Admin Service"]
        EventsAPI["Events Service"]
    end

    %% Deployment
    Firebase["Firebase Hosting"]
    click Firebase "https://github.com/entur/ninkasi/blob/master/firebase.json"

    %% Relationships
    App --> UI
    App --> State
    App --> Config
    App --> Screens
    App --> Auth
    Auth --> Services
    State --> Services
    Screens --> Services

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef frontend fill:#ddf1fd,stroke:#0077b6
    classDef auth fill:#d1fae5,stroke:#059669
    classDef service fill:#fde68a,stroke:#d97706
    classDef config fill:#e5e7eb,stroke:#4b5563
    
    class App,UI,State,Config,Screens frontend
    class Auth,Keycloak,JWTHandler auth
    class Services,ProvidersAPI,OrgsAPI,TimetableAPI,MapAPI,GeocoderAPI,EventsAPI service
    class Firebase,ConfigContext,EnvConfig config
```
