# digitalservicebund/steuerlotse architecture

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

- Interactive diagram: https://gitdiagram.com/digitalservicebund/steuerlotse
- Repository: https://github.com/digitalservicebund/steuerlotse

## Overview

##### Main Components

a. Frontend Layer:
- React-based client application (webapp/client)
- Storybook for component documentation

b. Backend Layer:
- Flask web application (webapp/app)
- Form handling system (webapp/app/forms)
- Authentication and encryption (webapp/app/crypto)
- Data access layer (webapp/app/data_access)

c. Storage Layer:
- PostgreSQL database
- Redis for server-side sessions (as per ADR 0002)

d. External Services:
- ELSTER integration via Erica service
- Email service (webapp/app/email)

##### Key Architectural Patterns to Highlight

a. Multi-step Form Flow Architecture:
- Flow management system (webapp/app/forms/flows)
- Step handling (webapp/app/forms/steps)
- Form validation (webapp/app/forms/validations)

b. Data Management:
- Model layer (webapp/app/model)
- Database models (webapp/app/data_access/db_model)
- Storage implementations (webapp/app/data_access/storage)

**[Frontend Layer]**
**React Components <-> React Pages <-> Static Assets**
- ↕
**[API Layer]**
**Flask Routes <-> Form Flows <-> Step Management**
- ↕
**[Service Layer]**
**User Controller <-> Form Storage <-> Encryption**
- ↕
**[Data Layer]**
**PostgreSQL <-> Redis Sessions**
- ↕
**[External Services]**
**ELSTER (Erica) <-> Email Service**

##### Important Elements

a. Security Components:
- Encryption service
- Password hashing
- Session management
- Audit logging

b. Integration Points:
- ELSTER client integration
- Email service integration
- Database connections
- Redis session storage

c. Development Tools:
- Storybook integration
- Testing infrastructure
- CI/CD pipelines

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef devops fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        ReactApp["React Application"]:::frontend
        Storybook["Storybook"]:::frontend
        StaticAssets["Static Assets"]:::frontend
        Components["Component Library"]:::frontend
        
        ReactApp --> Components
        ReactApp --> StaticAssets
        Components --> Storybook
    end

    %% Backend Layer
    subgraph Backend
        Flask["Flask Application"]:::backend
        FormSystem["Form Handling System"]:::backend
        AuthCrypto["Authentication/Encryption"]:::backend
        DataAccess["Data Access Layer"]:::backend
        
        Flask --> FormSystem
        Flask --> AuthCrypto
        Flask --> DataAccess
    end

    %% Storage Layer
    subgraph Storage
        DBModels["Database Models"]:::storage
        Redis["Redis Sessions"]:::storage
        FormStorage["Form Storage"]:::storage
        PostgreSQL[(PostgreSQL)]:::storage
        
        DBModels --> PostgreSQL
        Redis --> FormStorage
    end

    %% External Services
    subgraph External
        Elster["ELSTER Integration"]:::external
        Email["Email Service"]:::external
    end

    %% Additional Components
    subgraph Core
        FormFlows["Multi-step Form Flows"]:::backend
        Validation["Form Validation"]:::backend
        I18n["Internationalization"]:::backend
        APIRoutes["API Routes"]:::backend
        AuditLog["Audit Logging"]:::security
        Config["Configuration"]:::backend
    end

    %% Development Infrastructure
    subgraph DevOps
        CICD["CI/CD Pipelines"]:::devops
        Docker["Docker Configuration"]:::devops
        Testing["Testing Infrastructure"]:::devops
    end

    %% Relationships
    Frontend --> APIRoutes
    APIRoutes --> FormSystem
    FormSystem --> FormFlows
    FormFlows --> Validation
    DataAccess --> Storage
    AuthCrypto --> Redis
    FormSystem --> Elster
    FormSystem --> Email
    DataAccess --> AuditLog

    %% Click events
    click ReactApp "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/client/src/"
    click Storybook "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/client/.storybook/"
    click StaticAssets "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/client/public/"
    click Components "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/client/src/components/"
    click Flask "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/app/"
    click FormSystem "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/app/forms/"
    click AuthCrypto "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/app/crypto/"
    click DataAccess "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/app/data_access/"
    click DBModels "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/app/data_access/db_model/"
    click Redis "https://github.com/digitalservicebund/steuerlotse/blob/main/webapp/app/data_access/storage/session_storage.py"
    click FormStorage "https://github.com/digitalservicebund/steuerlotse/blob/main/webapp/app/data_access/storage/form_storage.py"
    click Elster "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/app/elster_client/"
    click Email "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/app/email/"
    click FormFlows "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/app/forms/flows/"
    click Validation "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/app/forms/validations/"
    click I18n "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/app/translations/"
    click APIRoutes "https://github.com/digitalservicebund/steuerlotse/blob/main/webapp/app/routes.py"
    click AuditLog "https://github.com/digitalservicebund/steuerlotse/blob/main/webapp/app/data_access/audit_log_controller.py"
    click Config "https://github.com/digitalservicebund/steuerlotse/blob/main/webapp/app/config.py"
    click CICD "https://github.com/digitalservicebund/steuerlotse/tree/main/.github/workflows/"
    click Docker "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/Dockerfile"
    click Testing "https://github.com/digitalservicebund/steuerlotse/tree/main/webapp/tests/"
```
