# klayrhapsody/dev-habit architecture

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

- Interactive diagram: https://gitdiagram.com/klayrhapsody/dev-habit
- Repository: https://github.com/klayrhapsody/dev-habit

## Overview

##### Project Type & Purpose
- The project is a full-stack RESTful application called “Dev Habit,” which manages habits, entries, tags, GitHub integrations, and user accounts.
- The backend is built with ASP.NET Core, employing controllers, DTOs, Entity Framework Core with migrations, various middleware (global error handling, ETag, etc.) and scheduled jobs for automating GitHub-related tasks.
- The frontend is a modern client-side application (in the “client/devhabit-ui” folder) likely built using React (via Vite, TypeScript, Tailwind CSS) and communicates with the API.

##### Analysis of the File Structure
- The solution divides responsibility clearly:
- The “DevHabit” directory holds the backend API code. Inside it:
▪ Controllers for multiple API endpoints (auth, entries, habits, tags, GitHub integration, users).
▪ DTOs grouped by functionality and corresponding validation.
▪ An Entities folder and EF Core Database Configurations for domain modeling and data persistence – including separate DbContexts for application and identity.
▪ Middleware, Jobs, and Services implementing additional business logic (e.g., GitHub automation, media type handling, custom error responses).
▪ Migrations and configuration files (e.g., appsettings, Dockerfile, docker-compose) that indicate a containerized deployment approach.
- The “client/devhabit-ui” directory encapsulates the frontend code, configuration files like Vite config, Tailwind, and component structure (authentication, layout, habits, entries, tags, and users).
- Several Docker-related files and GitHub workflows exist for continuous integration and container orchestration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        F["DevHabit UI"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        C["Controllers"]:::backend
        D["DTOs"]:::backend
        M["Middleware"]:::backend
        S["Services"]:::backend
        J["Scheduled Jobs"]:::backend
        DB["Database & Migrations"]:::database
    end

    %% External Integrations
    subgraph "External Integrations"
        G["GitHub API"]:::external
    end

    %% Infrastructure & Deployment
    subgraph "Infrastructure"
        DC1["Docker Compose"]:::deployment
        DC2["Docker Compose Override"]:::deployment
    end

    %% Data Flow
    F -->|"HTTPREST"| C
    C -->|"Uses"| S
    C -->|"ValidatesWith"| D
    M -.->|"Intercepts"| C
    S -->|"DataAccess"| DB
    S -->|"Calls"| G
    J -->|"Triggers"| S
    DB -->|"PersistsData"| S

    %% Container orchestration connections (deployment orchestrates key components)
    DC1 -->|"Orchestrates"| F
    DC1 -->|"Orchestrates"| C
    DC1 -->|"Orchestrates"| DB

    DC2 -->|"Orchestrates"| F
    DC2 -->|"Orchestrates"| C
    DC2 -->|"Orchestrates"| DB

    %% Click Events
    click F "https://github.com/klayrhapsody/dev-habit/tree/main/client/devhabit-ui"
    click C "https://github.com/klayrhapsody/dev-habit/tree/main/DevHabit/DevHabit.Api/Controllers"
    click D "https://github.com/klayrhapsody/dev-habit/tree/main/DevHabit/DevHabit.Api/DTOs"
    click DB "https://github.com/klayrhapsody/dev-habit/tree/main/DevHabit/DevHabit.Api/Database"
    click M "https://github.com/klayrhapsody/dev-habit/tree/main/DevHabit/DevHabit.Api/Middleware"
    click J "https://github.com/klayrhapsody/dev-habit/tree/main/DevHabit/DevHabit.Api/Jobs"
    click S "https://github.com/klayrhapsody/dev-habit/tree/main/DevHabit/DevHabit.Api/Services"
    click DC1 "https://github.com/klayrhapsody/dev-habit/blob/main/DevHabit/docker-compose.yml"
    click DC2 "https://github.com/klayrhapsody/dev-habit/blob/main/DevHabit/docker-compose.override.yml"

    %% Styles
    classDef frontend fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef backend fill:#fad7a0,stroke:#d35400,stroke-width:2px;
    classDef database fill:#abebc6,stroke:#1e8449,stroke-width:2px;
    classDef external fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef deployment fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
```
