# taskemapp/server architecture

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

- Interactive diagram: https://gitdiagram.com/taskemapp/server
- Repository: https://github.com/taskemapp/server

## Overview

##### Main Components Identification

The system consists of two main microservices and supporting libraries:
- Server Application (Main API service)
- Notification Service
- Shared Libraries (queue, template)

##### Key Architectural Elements

A. Server Application Components:
- gRPC Services:
- Auth Service
- Profile Service
- Team Service
- Task Service
- File Service

B. Data Storage:
- PostgreSQL (indicated by pgx repositories)
- Redis (for token management)
- S3 (for file storage)

C. Notification Service:
- Email Notifications
- FCM (Firebase Cloud Messaging)

##### Specific Elements

- Blue: Core services
- Green: Storage systems
- Yellow: External services (FCM)
- Purple: Authentication components
- Gray: Supporting infrastructure

##### Implementation Details

**┌─────────────────┐**
- Service Name    │
- ┤
- Key Features  │
- Technologies  │
- ┘

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef external fill:#e6e6e6,stroke:#333
    classDef api fill:#b3d9ff,stroke:#333
    classDef service fill:#99ccff,stroke:#333
    classDef storage fill:#90EE90,stroke:#333
    classDef notification fill:#ffdb4d,stroke:#333
    classDef auth fill:#e6b3ff,stroke:#333
    classDef infrastructure fill:#d9d9d9,stroke:#333
    classDef repository fill:#ffd9b3,stroke:#333

    %% External Clients
    Client1["gRPC Client"]:::external
    Client2["gRPC Client"]:::external

    %% API Gateway Layer
    subgraph Gateway
        Interceptors["gRPC Interceptors"]:::api
    end
    click Interceptors "https://github.com/taskemapp/server/tree/dev/apps/server/internal/grpc/interceptor"

    %% Main Server Services
    subgraph ServerApp["Server Application"]
        AuthService["Auth Service"]:::auth
        ProfileService["Profile Service"]:::service
        TeamService["Team Service"]:::service
        TaskService["Task Service"]:::service
        FileService["File Service"]:::service
        JWTHandler["JWT Handler"]:::auth
    end
    click ServerApp "https://github.com/taskemapp/server/tree/dev/apps/server"
    click AuthService "https://github.com/taskemapp/server/tree/dev/apps/server/internal/grpc/auth"
    click ProfileService "https://github.com/taskemapp/server/tree/dev/apps/server/internal/grpc/profile"
    click TeamService "https://github.com/taskemapp/server/tree/dev/apps/server/internal/grpc/team"
    click JWTHandler "https://github.com/taskemapp/server/tree/dev/apps/server/internal/pkg/jwt"

    %% Repositories
    subgraph Repositories
        UserRepo["User Repository"]:::repository
        TeamRepo["Team Repository"]:::repository
        TaskRepo["Task Repository"]:::repository
        TokenRepo["Token Repository"]:::repository
        FileRepo["User File Repository"]:::repository
    end
    click UserRepo "https://github.com/taskemapp/server/tree/dev/apps/server/internal/repository/user"
    click TeamRepo "https://github.com/taskemapp/server/tree/dev/apps/server/internal/repository/team"
    click TaskRepo "https://github.com/taskemapp/server/tree/dev/apps/server/internal/repository/task"
    click TokenRepo "https://github.com/taskemapp/server/tree/dev/apps/server/internal/repository/token"
    click FileRepo "https://github.com/taskemapp/server/tree/dev/apps/server/internal/repository/user_file"

    %% Storage Layer
    subgraph Storage
        PostgreSQL[(PostgreSQL)]:::storage
        Redis[(Redis)]:::storage
        S3["S3 Storage"]:::storage
        Migrations["DB Migrations"]:::infrastructure
    end
    click S3 "https://github.com/taskemapp/server/tree/dev/apps/server/internal/pkg/s3"
    click Migrations "https://github.com/taskemapp/server/tree/dev/migrations"

    %% Notification Service
    subgraph NotificationService["Notification Service"]
        EmailNotifier["Email Notifier"]:::notification
        FCMNotifier["FCM Notifier"]:::notification
        Templates["Email Templates"]:::notification
        Queue["Message Queue"]:::infrastructure
    end
    click NotificationService "https://github.com/taskemapp/server/tree/dev/apps/notification"
    click EmailNotifier "https://github.com/taskemapp/server/blob/dev/apps/notification/internal/notifier/email.go"
    click FCMNotifier "https://github.com/taskemapp/server/blob/dev/apps/notification/internal/notifier/fcm.go"
    click Templates "https://github.com/taskemapp/server/tree/dev/apps/server/internal/pkg/notifier/templates"
    click Queue "https://github.com/taskemapp/server/tree/dev/libs/queue"

    %% Connections
    Client1 --> Interceptors
    Client2 --> Interceptors
    Interceptors --> AuthService
    Interceptors --> ProfileService
    Interceptors --> TeamService
    Interceptors --> TaskService
    Interceptors --> FileService
    
    AuthService --> JWTHandler
    AuthService --> UserRepo
    ProfileService --> UserRepo
    TeamService --> TeamRepo
    TaskService --> TaskRepo
    FileService --> FileRepo
    
    UserRepo --> PostgreSQL
    TeamRepo --> PostgreSQL
    TaskRepo --> PostgreSQL
    TokenRepo --> Redis
    FileRepo --> S3
    
    Migrations --> PostgreSQL
    
    AuthService -.-> Queue
    TaskService -.-> Queue
    Queue --> EmailNotifier
    Queue --> FCMNotifier
    Templates --> EmailNotifier

    %% Legend
    subgraph Legend
        L1["External Client"]:::external
        L2["API Component"]:::api
        L3["Core Service"]:::service
        L4["Storage"]:::storage
        L5["Notification"]:::notification
        L6["Auth Component"]:::auth
        L7["Repository"]:::repository
        L8["Infrastructure"]:::infrastructure
    end
```
