# devlulcas/coatiquati architecture

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

- Interactive diagram: https://gitdiagram.com/devlulcas/coatiquati
- Repository: https://github.com/devlulcas/coatiquati

## Overview

##### High-Level Architecture Components

a) Frontend Layer:
- Next.js App Router-based frontend (src/app directory)
- Client-side components and pages
- UI components (src/shared/components/ui)

b) Backend Layer:
- Next.js API routes (src/app/api)
- Authentication system (Lucia)
- Email service (AWS SES)
- File storage (AWS S3)

c) Database Layer:
- Turso Database (SQLite-based)
- Drizzle ORM integration

##### Core Module Organization

Create distinct sections for the main functional modules:

a) Authentication & User Management:
- User authentication (src/modules/auth)
- User profiles (src/modules/user)
- User following system (src/modules/user-followings)

b) Content Management:
- Trails system (src/modules/trail)
- Topics management (src/modules/topic)
- Content types:
- Rich text (src/modules/rich-text-content)
- Images (src/modules/image-content)
- Videos (src/modules/video-content)

c) Social Features:
- Comments system (src/modules/comments)
- Publications (src/modules/publication)
- Feedback system (src/modules/feedback)

##### Key Flows to Highlight

Important processes:

a) Authentication Flow:
- Sign-up/Sign-in process
- Email verification
- Session management

b) Content Creation Flow:
- Trail creation
- Topic management
- Content publication process

c) Social Interaction Flow:
- Comment system
- User following
- Content voting

##### External Services Integration

Integration points:

a) AWS Services:
- S3 for file storage
- SES for email delivery

b) Database:
- Turso connection
- Migration system

##### Security Layer

Security implementations:

- Authentication middleware
- Role-based access control
- API route protection

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        FE[Next.js Frontend]
        UI[UI Components]
        CR[Content Renderer]
    end

    subgraph Backend
        API[API Routes]
        Auth[Authentication System]
        UM[User Management]
        UMod[User Moderation]
        
        subgraph ContentManagement
            Trails[Trails System]
            Topics[Topics System]
            RT[Rich Text Content]
            IC[Image Content]
            VC[Video Content]
        end
        
        subgraph SocialFeatures
            Comments[Comments System]
            Pub[Publications]
            Feed[Feedback System]
            UF[User Following]
        end
        
        subgraph ExternalServices
            AWS[AWS Integration]
            Email[Email System]
            FS[File Storage]
        end
    end

    subgraph Database
        DB[(Turso Database)]
        Schema[Database Schema]
    end

    %% Frontend Connections
    FE --> API
    FE --> UI
    FE --> CR

    %% Backend Connections
    API --> Auth
    API --> UM
    API --> UMod
    API --> ContentManagement
    API --> SocialFeatures
    API --> ExternalServices

    %% Content Management Connections
    Trails --> DB
    Topics --> DB
    RT --> DB
    IC --> DB
    VC --> DB

    %% Social Features Connections
    Comments --> DB
    Pub --> DB
    Feed --> DB
    UF --> DB

    %% External Services Connections
    AWS --> Email
    AWS --> FS
    Email --> DB
    FS --> DB

    %% Database Connections
    DB --> Schema

    %% Styling
    classDef frontend fill:#a8d1ff
    classDef backend fill:#90EE90
    classDef database fill:#DDA0DD
    classDef external fill:#FFD700

    class FE,UI,CR frontend
    class API,Auth,UM,UMod,Trails,Topics,RT,IC,VC,Comments,Pub,Feed,UF backend
    class DB,Schema database
    class AWS,Email,FS external

    %% Click Events
    click FE "https://github.com/devlulcas/coatiquati/tree/main/src/app"
    click API "https://github.com/devlulcas/coatiquati/tree/main/src/app/api"
    click Auth "https://github.com/devlulcas/coatiquati/tree/main/src/modules/auth"
    click UM "https://github.com/devlulcas/coatiquati/tree/main/src/modules/user"
    click UMod "https://github.com/devlulcas/coatiquati/tree/main/src/modules/user-moderation"
    click Trails "https://github.com/devlulcas/coatiquati/tree/main/src/modules/trail"
    click Topics "https://github.com/devlulcas/coatiquati/tree/main/src/modules/topic"
    click RT "https://github.com/devlulcas/coatiquati/tree/main/src/modules/rich-text-content"
    click IC "https://github.com/devlulcas/coatiquati/tree/main/src/modules/image-content"
    click VC "https://github.com/devlulcas/coatiquati/tree/main/src/modules/video-content"
    click Comments "https://github.com/devlulcas/coatiquati/tree/main/src/modules/comments"
    click Pub "https://github.com/devlulcas/coatiquati/tree/main/src/modules/publication"
    click Feed "https://github.com/devlulcas/coatiquati/tree/main/src/modules/feedback"
    click UF "https://github.com/devlulcas/coatiquati/tree/main/src/modules/user-followings"
    click AWS "https://github.com/devlulcas/coatiquati/tree/main/src/modules/aws"
    click Email "https://github.com/devlulcas/coatiquati/tree/main/src/modules/email"
    click FS "https://github.com/devlulcas/coatiquati/tree/main/src/modules/file"
    click DB "https://github.com/devlulcas/coatiquati/tree/main/src/modules/database"
    click Schema "https://github.com/devlulcas/coatiquati/tree/main/src/modules/database/schema"
    click UI "https://github.com/devlulcas/coatiquati/tree/main/src/shared/components/ui"
    click CR "https://github.com/devlulcas/coatiquati/tree/main/src/modules/content-renderer"
```
