# ocvt/dolabra architecture

> Architecture diagram of the GitHub repository ocvt/dolabra, 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/ocvt/dolabra
- Repository: https://github.com/ocvt/dolabra

## Overview

##### Main Components Identification

a) Core Application Components:
- API Server (Go-based)
- Database Layer
- Authentication System
- Email Notification System
- Payment Processing
- Photo Management System

##### External Services Integration
- Google Drive (photo storage)
- AWS SES (email service)
- Stripe (payment processing)
- Google OAuth (authentication)

##### Detailed Component Breakdown

API Layer (Group the handlers by function):
- Trip Management (/trips*, /trips_signup*, /trips_approval*)
- User Management (/myaccount*)
- Admin Tools (/webtools*)
- Authentication (/auth*)
- Notifications (/notify*)
- Payment Processing (/payment*)
- Photo Management (/photos*)

Database Layer:
- Main database tables (implied by handler structure)
- Migration utilities connection

External Services Layer:
- Google Drive Integration
- AWS SES Email Service
- Stripe Payment Processing
- Authentication Services

##### Flow Representations

- Authentication flow (user → Google OAuth → API)
- Trip management flow (creation → approval → signup)
- Payment processing flow (user → Stripe → API)
- Photo management flow (API → Google Drive)
- Notification flow (API → AWS SES → Users)

##### Important Details

Annotations for:
- Environment configuration requirements
- Security boundaries
- Development mode specifics
- Cookie domain sharing between API and frontend
- System account email handling

##### Architectural Patterns to Highlight

Emphasize:
- Handler-based API architecture
- Middleware implementation
- Service integration patterns
- Authentication flow

##### Data Storage Layer

Remember to:
- Version information and environment requirements
- Development vs production configurations
- Security boundaries and authentication checkpoints
- Where environment variables are used

This structure reflects the modular nature of the application while showing the clear separation of concerns between different components, making it easier to understand both the overall system and specific feature implementations.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Frontend[Frontend Application]
    end

    subgraph "API Gateway"
        API[API Server]:::apiserver
        Middleware[Request Middleware]:::middleware
    end

    subgraph "Core Services"
        direction TB
        Auth[Authentication Handler]:::auth
        Trips[Trip Management]:::core
        UserMgmt[User Management]:::core
        AdminTools[Admin Tools]:::core
        Notify[Notification System]:::core
        Payment[Payment Processing]:::core
        Photos[Photo Management]:::core
        CommonDB[Common DB Operations]:::core
    end

    subgraph "External Services"
        GDrive[Google Drive]:::external
        AWSSES[AWS SES]:::external
        Stripe[Stripe Payments]:::external
        GOAuth[Google OAuth]:::external
    end

    subgraph "Data Layer"
        DB[(Database)]:::database
        Config[Configuration]:::config
        Migrations[Migration Tools]:::utility
    end

    %% Connections
    Frontend --> API
    API --> Middleware
    Middleware --> Auth
    Middleware --> Trips
    Middleware --> UserMgmt
    Middleware --> AdminTools
    Middleware --> Notify
    Middleware --> Payment
    Middleware --> Photos

    Auth --> GOAuth
    Auth --> CommonDB
    Trips --> CommonDB
    UserMgmt --> CommonDB
    AdminTools --> CommonDB
    Notify --> AWSSES
    Payment --> Stripe
    Photos --> GDrive

    CommonDB --> DB
    Migrations --> DB
    Config --> API

    %% Click Events
    click API "https://github.com/ocvt/dolabra/blob/master/app/app.go"
    click Auth "https://github.com/ocvt/dolabra/blob/master/app/handler/auth.go"
    click Notify "https://github.com/ocvt/dolabra/blob/master/app/handler/notify.go"
    click Payment "https://github.com/ocvt/dolabra/blob/master/app/handler/payment.go"
    click Photos "https://github.com/ocvt/dolabra/blob/master/app/handler/photos.go"
    click Trips "https://github.com/ocvt/dolabra/blob/master/app/handler/trips.go"
    click UserMgmt "https://github.com/ocvt/dolabra/blob/master/app/handler/myaccount.go"
    click AdminTools "https://github.com/ocvt/dolabra/blob/master/app/handler/webtools_approvers.go"
    click CommonDB "https://github.com/ocvt/dolabra/blob/master/app/handler/commondb.go"
    click Middleware "https://github.com/ocvt/dolabra/blob/master/app/handler/middleware.go"
    click Config "https://github.com/ocvt/dolabra/blob/master/utils/config.go"
    click DB "https://github.com/ocvt/dolabra/blob/master/utils/dolabra-sqlite.sql"
    click Migrations "https://github.com/ocvt/dolabra/blob/master/utils/migrate.py"

    %% Styling
    classDef core fill:#2196F3,color:white
    classDef auth fill:#FF9800,color:white
    classDef external fill:#4CAF50,color:white
    classDef database fill:#607D8B,color:white
    classDef config fill:#9E9E9E,color:white
    classDef utility fill:#9E9E9E,color:white
    classDef apiserver fill:#1976D2,color:white
    classDef middleware fill:#FFA726,color:white

    %% Legend
    subgraph Legend
        L1[Core Services]:::core
        L2[Auth Components]:::auth
        L3[External Services]:::external
        L4[Data Storage]:::database
        L5[Configuration/Utilities]:::utility
    end
```
