# kirch2/cryptocurrently architecture

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

- Interactive diagram: https://gitdiagram.com/kirch2/cryptocurrently
- Repository: https://github.com/kirch2/cryptocurrently

## Overview

##### Main Components

a. Frontend Layer (React/TypeScript Application):
- User Interface Components (organize in groups):
- Authentication (Login/Register/Profile)
- Crypto Management (CryptoList, CryptoAlerts)
- Watchlist Management (WatchList components)
- State Management & API Integration

b. Backend Layer (Ruby on Rails API):
- Controllers Layer
- Model Layer (Active Record)
- Background Jobs (Resque)
- Mailer System

c. External Services:
- AWS Simple Email Service
- Cryptocurrency Data Source (implied by sync jobs)

d. Database Layer:
- PostgreSQL Database
- Key Entities: Users, Cryptocurrencies, Watchlists, Alerts

##### Component Relationships and Data Flow

- Frontend → Backend: RESTful API calls
- Backend → Database: Active Record operations
- Backend → AWS SES: Email notifications
- Background Jobs → External Crypto API: Price updates
- Background Jobs → Database: Price updates
- Mailer → AWS SES: Alert notifications

##### Specific Implementation Details

- Blue rectangles: Frontend components
- Green rectangles: Backend controllers
- Yellow diamonds: Background jobs
- Orange clouds: External services

##### Detailed Component Breakdown

Frontend (React/TypeScript):
- Components Layer
- Authentication Components
- Crypto Management Components
- Watchlist Components
- Pages Layer

Backend (Rails):
- API Controllers
- Models
- Background Jobs
- CryptoSyncAll
- CryptoSyncTop
- CryptoAlertSendAll
- Mailers

##### Key Architectural Patterns to Highlight

- MVC Pattern in Rails backend
- Component-based architecture in React frontend
- Background job processing with Resque
- RESTful API design
- Active Record ORM pattern

##### Technical Stack Callouts

Technologies:
- Frontend: React, TypeScript, Bootstrap
- Backend: Ruby on Rails
- Database: PostgreSQL
- Job Processing: Resque
- Email Service: AWS SES

##### Watchlist management

This system design should effectively communicate both the overall architecture and the specific implementation details of the CryptoCurrently application.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI[User Interface]
        
        subgraph AuthComponents
            Login["Login"]:::frontend
            Register["Register"]:::frontend
            Profile["Profile"]:::frontend
            UserAuth["User Authenticator"]:::frontend
        end
        
        subgraph CryptoComponents
            CryptoList["Crypto List"]:::frontend
            CryptoCard["Crypto Card"]:::frontend
            CryptoAlerts["Crypto Alerts"]:::frontend
            AlertCreator["Alert Creator"]:::frontend
        end
        
        subgraph WatchlistComponents
            WatchList["Watch List"]:::frontend
            WatchListId["Watch List Detail"]:::frontend
            WatchListCreator["Watch List Creator"]:::frontend
            WatchListForm["Watch List Form"]:::frontend
        end
    end
    
    subgraph Backend
        subgraph Controllers
            UserCtrl["Users Controller"]:::controller
            CryptoCtrl["Cryptocurrencies Controller"]:::controller
            AlertCtrl["Crypto Alerts Controller"]:::controller
            WatchlistCtrl["Watchlists Controller"]:::controller
        end
        
        subgraph Models
            UserModel["User Model"]:::model
            CryptoModel["Cryptocurrency Model"]:::model
            AlertModel["Crypto Alert Model"]:::model
            WatchlistModel["Watchlist Model"]:::model
        end
        
        subgraph Jobs
            SyncAll["Crypto Sync All"]:::job
            SyncTop["Crypto Sync Top"]:::job
            AlertSend["Crypto Alert Send All"]:::job
        end
        
        Mailer["Crypto Alert Mailer"]:::mailer
    end
    
    subgraph External
        DB[(PostgreSQL)]:::database
        AWS["AWS SES"]:::external
        CryptoAPI["Crypto API"]:::external
    end
    
    %% Frontend to Backend Connections
    UI --> Controllers
    
    %% Controller to Model Connections
    UserCtrl --> UserModel
    CryptoCtrl --> CryptoModel
    AlertCtrl --> AlertModel
    WatchlistCtrl --> WatchlistModel
    
    %% Model to Database Connections
    UserModel --> DB
    CryptoModel --> DB
    AlertModel --> DB
    WatchlistModel --> DB
    
    %% Job Connections
    SyncAll --> CryptoAPI
    SyncTop --> CryptoAPI
    AlertSend --> Mailer
    Mailer --> AWS
    
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef controller fill:#2ecc71,stroke:#27ae60,color:white
    classDef model fill:#f1c40f,stroke:#f39c12,color:black
    classDef job fill:#e74c3c,stroke:#c0392b,color:white
    classDef mailer fill:#9b59b6,stroke:#8e44ad,color:white
    classDef database fill:#34495e,stroke:#2c3e50,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    
    %% Click Events
    click Login "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/pages/Login.tsx"
    click Register "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/pages/Register.tsx"
    click Profile "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/pages/Profile.tsx"
    click UserAuth "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/components/UserAuthenticator/index.tsx"
    click CryptoList "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/pages/CryptoList.tsx"
    click CryptoCard "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/components/CryptoCard/index.tsx"
    click CryptoAlerts "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/pages/CryptoAlertList.tsx"
    click AlertCreator "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/components/CryptoAlertCreator/index.tsx"
    click WatchList "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/pages/WatchList.tsx"
    click WatchListId "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/pages/WatchListId.tsx"
    click WatchListCreator "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/components/WatchListCreator/index.tsx"
    click WatchListForm "https://github.com/Kirch2/CryptoCurrently/blob/main/client/src/components/WatchListForm/index.tsx"
    click UserCtrl "https://github.com/Kirch2/CryptoCurrently/blob/main/app/controllers/users_controller.rb"
    click CryptoCtrl "https://github.com/Kirch2/CryptoCurrently/blob/main/app/controllers/cryptocurrencies_controller.rb"
    click AlertCtrl "https://github.com/Kirch2/CryptoCurrently/blob/main/app/controllers/crypto_alerts_controller.rb"
    click WatchlistCtrl "https://github.com/Kirch2/CryptoCurrently/blob/main/app/controllers/watchlists_controller.rb"
    click UserModel "https://github.com/Kirch2/CryptoCurrently/blob/main/app/models/user.rb"
    click CryptoModel "https://github.com/Kirch2/CryptoCurrently/blob/main/app/models/cryptocurrency.rb"
    click AlertModel "https://github.com/Kirch2/CryptoCurrently/blob/main/app/models/crypto_alert.rb"
    click WatchlistModel "https://github.com/Kirch2/CryptoCurrently/blob/main/app/models/watchlist.rb"
    click SyncAll "https://github.com/Kirch2/CryptoCurrently/blob/main/app/jobs/crypto_sync_all.rb"
    click SyncTop "https://github.com/Kirch2/CryptoCurrently/blob/main/app/jobs/crypto_sync_top.rb"
    click AlertSend "https://github.com/Kirch2/CryptoCurrently/blob/main/app/jobs/crypto_alert_send_all.rb"
    click Mailer "https://github.com/Kirch2/CryptoCurrently/blob/main/app/mailers/crypto_alert_mailer.rb"
```
