# whyleonardo/dropcode architecture

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

- Interactive diagram: https://gitdiagram.com/whyleonardo/dropcode
- Repository: https://github.com/whyleonardo/dropcode

## Overview

##### Project Type and Purpose
- Dropcode is a monorepo-managed code-snippet manager.
- It hosts two frontends:
– `apps/marketing` (Astro-built static marketing site)
– `apps/web` (Next.js full-stack application for snippet management)
- Shared libraries/packages provide auth, DB, Redis, env, and config.

##### File Structure
- Top-level:
– `apps/marketing` – static site
– `apps/web` – React/Next.js app with API routes & server actions
– `packages/*` – reusable modules (`auth`, `db`, `redis`, `env`)
– `config/*` – custom Tailwind, asset, and TS config
– `turbo.json` – Turborepo build orchestration
– `docker-compose.yml` – local container setup
- `apps/web` contains:
– `src/app/api` (Next.js serverless routes using Auth.js)
– `src/data` (Zod schemas + server-side data functions)
– `src/components`, `src/lib`, `src/hooks`, `src/providers` (client + SSR)
- Packages:
– `packages/db` wraps Prisma → PostgreSQL
– `packages/redis` exports Redis client
– `packages/auth` configures Auth.js providers
– `packages/env` centralizes environment variables

##### README for Additional Insights
- Tech stack: Next.js, Astro, Turborepo, Docker, Prisma, Redis, Postgres, Auth.js, TypeScript, Tailwind, React Query, Zod, Framer Motion, etc.
- Features: snippet/file CRUD, analytics, authentication, caching, schema validation.

##### Components & Relationships
a. Main Components
– Frontends
- Marketing Site (Astro static pages)
- Web App (Next.js + React client + serverless API)
– Shared Packages (`auth`, `db`, `redis`, `env`)
– Build System (Turborepo)
– Database (PostgreSQL via Prisma)
– Cache (Redis)
– External Services (Auth providers via Auth.js, e.g., GitHub)
– DevOps (Docker Compose)
b. Interactions & Data Flows
– User → Browser → Marketing Site (static pages)
– User → Browser → Web App Client
– Web App Client → Next.js Server (API Routes / Server Actions)
– Next.js Server ↔ `packages/auth` (Auth.js config) for login/session
– Next.js Server ↔ `packages/db` (Prisma) → Postgres
– Next.js Server ↔ `packages/redis` → Redis (caching, sessions)
– Build System orchestrates dep graph: apps ← packages ← config
– Docker Compose spins up Postgres & Redis locally
c. Architectural Patterns & Design Principles
– Monorepo with Turborepo for parallel builds & caching
– Package-driven modularization (auth, db, redis, env)
– Next.js App Router + Server Actions (ZSA)
– Zod for runtime schema validation
– React Query / TanStack Query for data fetching & caching
– Tailwind CSS + Shadcn/Radix UI for styling
d. Key Technologies to Call Out
– Next.js (SSR, SSG, Server Actions)
– Astro (static marketing site)
– Prisma ORM → PostgreSQL
– Redis (in-memory cache)
– Auth.js (OAuth flows)
– Turborepo (monorepo orchestration)
– Docker Compose (local services)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontends
    subgraph "Frontends"
        Marketing["Marketing Site (Astro)"]:::frontend
        WebClient["Web App Client (React)"]:::frontend
    end

    %% Next.js Server
    subgraph "Next.js Server" 
        API["Next.js API Routes"]:::backend
        Actions["Server Actions & Zod Schemas"]:::backend
    end

    %% Shared Packages
    subgraph "Shared Packages"
        AuthPkg["Auth.js Config & Providers"]:::shared
        DBPkg["Prisma Client Wrapper"]:::shared
        RedisPkg["Redis Client"]:::shared
        EnvPkg["Environment Variables"]:::shared
    end

    %% Datastores
    Postgres[(PostgreSQL)]:::datastore
    Redis[(Redis)]:::datastore

    %% External Services
    AuthProvider["OAuth Providers (e.g., GitHub)"]:::external

    %% Configuration
    subgraph "Configuration"
        TailwindMark["Tailwind CSS (Marketing)"]:::config
        TailwindPreset["Tailwind CSS Preset"]:::config
        TSConfig["TypeScript Config"]:::config
        Assets["Asset Pipeline"]:::config
    end

    %% Build & DevOps
    BuildSys["Turborepo Build System"]:::devops
    DockerComp["Docker Compose"]:::devops

    %% Runtime Flows
    Marketing -->|serves static pages| User[(User Browser)]
    User -->|interacts| WebClient
    WebClient -->|calls| API
    WebClient -->|invokes| Actions
    API -->|uses| AuthPkg
    Actions -->|uses| AuthPkg
    API -->|queries| DBPkg
    Actions -->|queries| DBPkg
    API -->|caches| RedisPkg
    Actions -->|caches| RedisPkg

    %% Package to services
    AuthPkg -->|auth flows| AuthProvider
    DBPkg -->|ORM→| Postgres
    RedisPkg -->|cache| Redis

    %% DevOps
    DockerComp -->|spins up| Postgres
    DockerComp -->|spins up| Redis

    %% Build-time flows
    BuildSys --> Marketing
    BuildSys --> WebClient
    BuildSys --> AuthPkg
    BuildSys --> DBPkg
    BuildSys --> RedisPkg
    BuildSys --> EnvPkg
    BuildSys --> TailwindMark
    BuildSys --> TailwindPreset
    BuildSys --> TSConfig
    BuildSys --> Assets

    %% Config to apps
    TailwindMark --> Marketing
    TailwindPreset --> Marketing
    TSConfig --> Marketing
    Assets --> Marketing
    TailwindPreset --> WebClient
    TSConfig --> WebClient
    Assets --> WebClient
    EnvPkg --> WebClient
    EnvPkg --> Marketing

    %% Click Events
    click Marketing "https://github.com/whyleonardo/dropcode/tree/main/apps/marketing"
    click WebClient "https://github.com/whyleonardo/dropcode/tree/main/apps/web"
    click API "https://github.com/whyleonardo/dropcode/tree/main/apps/web/src/app/api"
    click AuthPkg "https://github.com/whyleonardo/dropcode/blob/main/packages/auth/src/auth.config.ts"
    click AuthPkg "https://github.com/whyleonardo/dropcode/blob/main/packages/auth/src/providers.ts"
    click DBPkg "https://github.com/whyleonardo/dropcode/blob/main/packages/db/src/index.ts"
    click Postgres "https://github.com/whyleonardo/dropcode/blob/main/packages/db/prisma/schema.prisma"
    click RedisPkg "https://github.com/whyleonardo/dropcode/blob/main/packages/redis/index.ts"
    click EnvPkg "https://github.com/whyleonardo/dropcode/blob/main/packages/env/src/web/index.ts"
    click BuildSys "https://github.com/whyleonardo/dropcode/blob/main/turbo.json"
    click BuildSys "https://github.com/whyleonardo/dropcode/blob/main/apps/web/turbo.json"
    click DockerComp "https://github.com/whyleonardo/dropcode/blob/main/docker-compose.yml"
    click TailwindMark "https://github.com/whyleonardo/dropcode/blob/main/apps/marketing/tailwind.config.ts"
    click TailwindPreset "https://github.com/whyleonardo/dropcode/blob/main/config/tailwind/src/preset.ts"
    click TSConfig "https://github.com/whyleonardo/dropcode/blob/main/config/ts-config/base.json"
    click Assets "https://github.com/whyleonardo/dropcode/blob/main/config/assets/src/fonts/stylesheet.css"
    click Actions "https://github.com/whyleonardo/dropcode/tree/main/apps/web/src/data"
    click QueryProv "https://github.com/whyleonardo/dropcode/blob/main/apps/web/src/providers/query-provider.tsx"
    click QueryLib "https://github.com/whyleonardo/dropcode/tree/main/apps/web/src/lib/tanstack-query"
    click UIComp "https://github.com/whyleonardo/dropcode/tree/main/apps/web/src/components/ui"
    click Layout "https://github.com/whyleonardo/dropcode/tree/main/apps/web/src/components/layout"
    click Sheets "https://github.com/whyleonardo/dropcode/tree/main/apps/web/src/components/sheets"
    click Globals "https://github.com/whyleonardo/dropcode/blob/main/apps/web/src/styles/globals.css"
    click Fonts "https://github.com/whyleonardo/dropcode/blob/main/apps/web/src/styles/fonts/index.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#888,stroke-width:1px
    classDef backend fill:#D0FFD6,stroke:#888,stroke-width:1px
    classDef datastore fill:#FFF6BF,stroke:#888,stroke-width:1px
    classDef shared fill:#E0E0E0,stroke:#888,stroke-width:1px
    classDef config fill:#F4D1FF,stroke:#888,stroke-width:1px
    classDef external fill:#FFD1D1,stroke:#888,stroke-width:1px
    classDef devops fill:#D1FFD6,stroke:#888,stroke-width:1px
```
