# varaprasadh/alienbook architecture

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

- Interactive diagram: https://gitdiagram.com/varaprasadh/alienbook
- Repository: https://github.com/varaprasadh/alienbook

## Overview

##### Main Components

a) Frontend Layer (Vue.js Application):
- Core Components (Posts, Comments, Reactions)
- State Management (Vuex Modules)
- Pages/Routes
- Asset Management

b) Backend Layer (Express.js Server):
- Authentication Service (Passport.js)
- Route Controllers
- Middleware Layer
- WebSocket Service (for real-time features)

c) Database Layer:
- Users
- Posts
- Comments
- Reactions
- Notifications
- Messages
- Conversations

d) External Services:
- Cloudinary for media storage
- Authentication providers (OAuth)

##### Component Relationships

- Client → Server: REST API calls
- Server → Database: Data operations
- Server → Cloudinary: Media upload/retrieval
- Server → Authentication Providers: OAuth flow
- WebSocket connections for real-time features

##### Specific Implementation Details

Frontend Structure:
**Vue.js Application**
- Components (Post, Comment, Reaction)
- Pages (Feed, Profile, Messaging)
- Vuex Store Modules
- Chat
- Editor
- Feed
- Notifications
- User
- Assets

Backend Structure:
**Express Server**
- Routes
- Auth
- Posts
- Comments
- Messaging
- Notifications
- Models
- Middleware
- Services

##### Scale Indicators

Notes about:
- Database indexing
- Caching layers
- Media storage optimization

Remember to include:
- Clear separation of concerns
- Security layers (middleware, authentication)
- Data flow patterns
- Service boundaries
- Integration points with external services

This will provide a comprehensive view of the AlienBook architecture while maintaining clarity and usefulness for development and deployment purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[Frontend Vue.js]
        subgraph Components
            Posts["Posts"]:::component
            Comments["Comments"]:::component
            Reactions["Reactions"]:::component
            ImageUpload["Image Upload"]:::component
        end
        subgraph "State Management"
            Chat["Chat Module"]:::state
            Editor["Editor Module"]:::state
            Feed["Feed Module"]:::state
            Notif["Notifications Module"]:::state
            User["User Module"]:::state
        end
    end

    subgraph Server
        BE[Backend Express.js]
        subgraph "Route Services"
            AuthService["Authentication Service"]:::service
            PostService["Post Service"]:::service
            CommentService["Comment Service"]:::service
            MsgService["Messaging Service"]:::service
            NotifService["Notification Service"]:::service
            ImageService["Image Service"]:::service
        end
        subgraph Middleware
            OAuth["OAuth"]:::middleware
            UserInfo["User Info"]:::middleware
            Sanitizer["Content Sanitizer"]:::middleware
        end
        WebSocket["WebSocket Service"]:::service
    end

    subgraph Database
        MongoDB[(MongoDB)]
        subgraph Collections
            Users[("Users")]:::db
            PostsDB[("Posts")]:::db
            CommentsDB[("Comments")]:::db
            ReactionsDB[("Reactions")]:::db
            NotificationsDB[("Notifications")]:::db
            MessagesDB[("Messages")]:::db
            ConversationsDB[("Conversations")]:::db
        end
    end

    subgraph "External Services"
        Cloudinary["Cloudinary"]:::external
        OAuthProviders["OAuth Providers"]:::external
    end

    %% Relationships
    FE --> BE
    BE --> MongoDB
    ImageService --> Cloudinary
    AuthService --> OAuthProviders
    WebSocket --> NotifService
    WebSocket --> MsgService

    %% Click Events
    click Posts "https://github.com/varaprasadh/Alienbook/blob/master/client/src/components/Post.vue"
    click Comments "https://github.com/varaprasadh/Alienbook/blob/master/client/src/components/Comment.vue"
    click Reactions "https://github.com/varaprasadh/Alienbook/blob/master/client/src/components/Reactions.vue"
    click Chat "https://github.com/varaprasadh/Alienbook/blob/master/client/src/store/modules/chat.js"
    click Editor "https://github.com/varaprasadh/Alienbook/blob/master/client/src/store/modules/editor.js"
    click Feed "https://github.com/varaprasadh/Alienbook/blob/master/client/src/store/modules/feed.js"
    click Notif "https://github.com/varaprasadh/Alienbook/blob/master/client/src/store/modules/notifications.js"
    click User "https://github.com/varaprasadh/Alienbook/blob/master/client/src/store/modules/user.js"
    click AuthService "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/auth.js"
    click PostService "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/PostService.js"
    click CommentService "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/commentHandler.js"
    click MsgService "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/Messaging/index.js"
    click NotifService "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/NotificationService.js"
    click Users "https://github.com/varaprasadh/Alienbook/blob/master/server/models/User.js"
    click PostsDB "https://github.com/varaprasadh/Alienbook/blob/master/server/models/Post.js"
    click CommentsDB "https://github.com/varaprasadh/Alienbook/blob/master/server/models/Comment.js"
    click ReactionsDB "https://github.com/varaprasadh/Alienbook/blob/master/server/models/Reaction.js"
    click NotificationsDB "https://github.com/varaprasadh/Alienbook/blob/master/server/models/Notification.js"
    click MessagesDB "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/Messaging/models/Message.js"
    click ConversationsDB "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/Messaging/models/Conversation.js"
    click OAuth "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/middlewares/oauth.js"
    click UserInfo "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/middlewares/attachUserInfo.js"
    click Sanitizer "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/middlewares/contentSanitizer.js"
    click ImageService "https://github.com/varaprasadh/Alienbook/blob/master/server/routes/imageService/index.js"
    click ImageUpload "https://github.com/varaprasadh/Alienbook/blob/master/client/src/components/UploadImageButton.vue"

    %% Styles
    classDef component fill:#2196F3,stroke:#1976D2,color:white
    classDef state fill:#4CAF50,stroke:#388E3C,color:white
    classDef service fill:#FF9800,stroke:#F57C00,color:white
    classDef middleware fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef db fill:#FFC107,stroke:#FFA000,color:black
    classDef external fill:#607D8B,stroke:#455A64,color:white

    %% Legend
    subgraph Legend
        L1["Frontend Component"]:::component
        L2["State Module"]:::state
        L3["Backend Service"]:::service
        L4["Middleware"]:::middleware
        L5["Database"]:::db
        L6["External Service"]:::external
    end
```
