# kaucrow/nexis architecture

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

- Interactive diagram: https://gitdiagram.com/kaucrow/nexis
- Repository: https://github.com/kaucrow/nexis

## Overview

##### High-Level Components

a) Client Layer:
- SvelteKit Frontend (app/frontend)
- Main routes: auth, user, and store-specific routes
- Stores component integration (Readon, Vesti, Cyberion, Savoro)

b) API Layer (show as two parallel services):
- Rust API (nexis-rs) - Primary authentication and core functionality
- Python API (nexis-py) - Secondary services
- Both with HTTPS endpoints

c) Data Layer:
- MongoDB (primary database for daily operations)
- PostgreSQL (data warehouse for analytics)
- Redis (for caching/sessions)

##### Detailed Component Breakdown

a) Frontend Architecture:
**Frontend (SvelteKit)**
- Components (lib/components)
- Stores (lib/stores)
- Utils (lib/utils)
- Routes
- Auth
- User
- Store-specific

b) Rust API Architecture:
**Rust API**
- Routes
- Health
- Users (auth, registration, session)
- Database
- Types
- Utils
- Auth

c) Database Models:
- Relationship between collections (User, Store, Products)
- Different product types (Clothes, Food, Tech, Library)

##### Interaction Flows

- Authentication flow (registration, login, session verification)
- Shopping operations
- Analytics data flow
- Real-time updates path

##### Notes Section

Annotations for:
- Shared authentication between APIs
- Development vs Production configurations
- Scaling considerations
- Security implementations

Remember to emphasize:
- The dual-API architecture
- The dual-database strategy (MongoDB/PostgreSQL)
- The four distinct store implementations
- The separation between customer and employee operations
- Real-time update mechanisms
- Analytics data flow

This will provide a comprehensive view of the system while maintaining clarity on the unique aspects of this mall management platform.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE["Frontend (SvelteKit)"]:::frontend
        click FE "https://github.com/Kaucrow/nexis/tree/main/app/frontend/src/"
        
        subgraph Routes
            Auth["Auth Routes"]:::frontend
            click Auth "https://github.com/Kaucrow/nexis/tree/main/app/frontend/src/routes/auth/"
            User["User Routes"]:::frontend
            click User "https://github.com/Kaucrow/nexis/tree/main/app/frontend/src/routes/user/"
            Store["Store Routes"]:::frontend
        end
        
        subgraph Components
            Comp["UI Components"]:::frontend
            click Comp "https://github.com/Kaucrow/nexis/tree/main/app/frontend/src/lib/components/"
            Utils["Frontend Utils"]:::frontend
            click Utils "https://github.com/Kaucrow/nexis/tree/main/app/frontend/src/lib/utils/"
            Stores["Frontend Stores"]:::frontend
            click Stores "https://github.com/Kaucrow/nexis/tree/main/app/frontend/src/lib/stores/"
        end
    end

    subgraph "API Layer"
        RustAPI["Rust API Service"]:::api
        click RustAPI "https://github.com/Kaucrow/nexis/tree/main/app/backend/nexis-rs/src/routes/"
        PythonAPI["Python API Service"]:::api
        click PythonAPI "https://github.com/Kaucrow/nexis/tree/main/app/backend/nexis-py/nexis_py/routes/"
        
        subgraph "Authentication"
            RustAuth["Rust Auth"]:::security
            click RustAuth "https://github.com/Kaucrow/nexis/tree/main/app/backend/nexis-rs/src/utils/auth/"
            PyAuth["Python Auth"]:::security
            click PyAuth "https://github.com/Kaucrow/nexis/tree/main/app/backend/nexis-py/nexis_py/utils/auth/"
        end
        
        subgraph "API Types"
            RustTypes["Rust Types"]:::types
            click RustTypes "https://github.com/Kaucrow/nexis/tree/main/app/backend/nexis-rs/src/types/"
            PyTypes["Python Types"]:::types
            click PyTypes "https://github.com/Kaucrow/nexis/tree/main/app/backend/nexis-py/nexis_py/types/"
        end
    end

    subgraph "Data Layer"
        MongoDB[(MongoDB)]:::database
        click MongoDB "https://github.com/Kaucrow/nexis/tree/main/db-model/mongodb/"
        PostgreSQL[(PostgreSQL)]:::database
        click PostgreSQL "https://github.com/Kaucrow/nexis/tree/main/db-model/postgresql/"
        Redis[(Redis Cache)]:::cache
        
        subgraph "MongoDB Collections"
            Users["Users"]:::collection
            click Users "https://github.com/Kaucrow/nexis/blob/main/db-model/mongodb/User.json"
            Stores["Stores"]:::collection
            click Stores "https://github.com/Kaucrow/nexis/blob/main/db-model/mongodb/Store.json"
            StoreJobs["Store Jobs"]:::collection
            click StoreJobs "https://github.com/Kaucrow/nexis/blob/main/db-model/mongodb/StoreJob.json"
            
            subgraph "Product Types"
                Clothes["Clothes"]:::product
                click Clothes "https://github.com/Kaucrow/nexis/blob/main/db-model/mongodb/Clothes.json"
                Food["Food"]:::product
                click Food "https://github.com/Kaucrow/nexis/blob/main/db-model/mongodb/Food.json"
                Tech["Tech"]:::product
                click Tech "https://github.com/Kaucrow/nexis/blob/main/db-model/mongodb/Tech.json"
                Library["Library Items"]:::product
                click Library "https://github.com/Kaucrow/nexis/blob/main/db-model/mongodb/LibraryItem.json"
            end
        end
    end

    %% Connections
    FE --> RustAPI
    FE --> PythonAPI
    RustAPI --> MongoDB
    PythonAPI --> MongoDB
    RustAPI --> PostgreSQL
    PythonAPI --> PostgreSQL
    RustAPI --> Redis
    PythonAPI --> Redis
    
    %% Authentication Flow
    Auth --> RustAuth
    RustAuth --> Users
    Auth --> PyAuth
    PyAuth --> Users

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:#fff
    classDef api fill:#2ecc71,stroke:#27ae60,color:#fff
    classDef security fill:#e74c3c,stroke:#c0392b,color:#fff
    classDef database fill:#f1c40f,stroke:#f39c12,color:#fff
    classDef cache fill:#95a5a6,stroke:#7f8c8d,color:#fff
    classDef collection fill:#e67e22,stroke:#d35400,color:#fff
    classDef product fill:#9b59b6,stroke:#8e44ad,color:#fff
    classDef types fill:#1abc9c,stroke:#16a085,color:#fff
```
