# muratcanyusufoglu/noveltales-story-generator-ai architecture

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

- Interactive diagram: https://gitdiagram.com/muratcanyusufoglu/noveltales-story-generator-ai
- Repository: https://github.com/muratcanyusufoglu/noveltales-story-generator-ai

## Overview

##### Main Components

a. Client Layer:
- React Native Mobile Application (Frontend)
- Key features: Story Generation, Authentication, Subscription Management
- Components structure following screens (Welcome, Home, Selection, Story Detail)
- State Management using MobX stores (AuthenticationStore, CreateStoryStore, etc.)

b. Server Layer:
- Node.js Backend
- RESTful API endpoints
- Database Models and Migrations
- Authentication & Authorization services

c. Database Layer:
- SQL Database (likely PostgreSQL based on Sequelize migrations)
- Core entities: User, Story, Character, Topic, Content, Location, Timelapse

d. External Services:
- AI Integration (for story generation)
- RevenueCat for payment processing
- Image caching service

##### Relationships to Highlight

- User flows through the selection screens (Topic → Character → Location → Time → Content)
- Story generation pipeline
- Authentication flow
- Subscription and payment processing flow
- Data relationships between models (e.g., Story-Character, Story-Location)

**[Mobile Client Layer]**
- UI Components
- Navigation
- State Management
- Services

**[API Layer]**
- REST Endpoints
- Authentication
- Business Logic

**[Data Layer]**
- Database Models
- External Services

##### Important Architectural Patterns to Highlight

- MVC pattern in the backend
- Store-based state management in frontend
- Screen-based navigation structure
- Service-oriented architecture for business logic
- Multi-language support (i18n)

##### Key Flows to Illustrate

a. Story Generation Flow:
**User Selection → Topic → Character → Location → Time → Content → AI Generation → Story Display**

b. Authentication Flow:
**Login/Signup → Token Generation → Protected Routes → User Session**

c. Data Flow:
**API Requests → Backend Routes → Controllers → Models → Database**

##### Additional Elements

- Error handling and boundary components
- Caching mechanisms for images and data
- Subscription system integration
- Internationalization flow
- Development/production environment configurations

##### Technical Details to Note

- Expo framework usage
- Mobile-specific considerations
- API versioning
- Database migrations
- Testing infrastructure

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        MA[Mobile App]
        click MA "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/App.tsx"
        
        subgraph Navigation
            AN[App Navigator]
            click AN "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/navigators/AppNavigator.tsx"
        end
        
        subgraph Screens
            WS[Welcome Screen]
            SS[Signup Screen]
            click SS "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/screens/SignupScreen/SignupScreen.tsx"
            SLS[Selection Screens]
            click SLS "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/tree/main/Frontend/app/screens/SelectionScreens/screens/"
        end
        
        subgraph "State Management"
            AS[Auth Store]
            click AS "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/store/AuthenticationStore.ts"
            CSS[Create Story Store]
            click CSS "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/store/CreateStoryStore.ts"
            SUS[Subscription Store]
            click SUS "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/store/SubscriptionStore.ts"
        end
        
        subgraph Services
            LS[Login Service]
            click LS "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/screens/WelcomeScreen/LoginService.tsx"
            SS2[Selection Service]
            click SS2 "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/screens/SelectionScreens/service/SelectService.tsx"
            ICS[Image Cache Service]
            click ICS "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/utils/ImageCacheService.ts"
            I18[i18n Service]
            click I18 "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/i18n/i18n.ts"
        end
        
        subgraph "API Client"
            AC[API Config]
            click AC "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/services/api/api.ts"
            AT[API Types]
            click AT "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/services/api/api.types.ts"
        end
    end
    
    subgraph Server
        NJS[Node.js Server]
        click NJS "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Backend/index.js"
        
        subgraph "API Routes"
            AR[API Routes]
            click AR "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/tree/main/Backend/routes/"
        end
        
        subgraph "Database Config"
            DC[DB Config]
            click DC "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Backend/config/database.js"
        end
        
        subgraph Models
            UM[User Model]
            click UM "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Backend/models/user.js"
            SM[Story Model]
            click SM "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Backend/models/story.js"
            CM[Character Model]
            click CM "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Backend/models/character.js"
            TM[Topic Model]
            click TM "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Backend/models/topic.js"
            LM[Location Model]
            click LM "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Backend/models/location.js"
        end
        
        subgraph Migrations
            MG[Migrations]
            click MG "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/tree/main/Backend/migrations/"
        end
    end
    
    subgraph "External Services"
        AI[AI Service]
        RC[RevenueCat]
        click RC "https://github.com/muratcanyusufoglu/noveltales-story-generator-ai/blob/main/Frontend/app/payment/reveneuCatProvider.tsx"
        DB[(Database)]
    end
    
    %% Relationships
    MA --> AN
    AN --> WS & SS & SLS
    MA --> AS & CSS & SUS
    WS --> LS
    SLS --> SS2
    MA --> ICS
    MA --> I18
    MA --> AC
    AC --> AT
    
    NJS --> AR
    NJS --> DC
    DC --> MG
    AR --> UM & SM & CM & TM & LM
    
    AC --> NJS
    NJS --> AI
    MA --> RC
    DC --> DB
    
    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    
    class MA,AN,WS,SS,SLS,AS,CSS,SUS,LS,SS2,ICS,I18,AC,AT frontend
    class NJS,AR,DC,UM,SM,CM,TM,LM,MG backend
    class DB database
    class AI,RC external
```
