# amirka2/unie architecture

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

- Interactive diagram: https://gitdiagram.com/amirka2/unie
- Repository: https://github.com/amirka2/unie

## Overview

##### Main Components Identification
- Client / Browser: Represents the end-user’s interface.
- Nginx Server: Acting as a reverse proxy (see the “nginx” directory and its Dockerfile and configuration files), it routes incoming HTTP requests to the appropriate service.
- Next.js Application Container: The core application container built from the Next.js code base. This includes both the frontend and backend API endpoints (see all files under the "src/app" directory).
- Prisma & Database: Although the actual database isn’t directly in the file tree, the presence of “prisma” directories with migrations, seed scripts, and a schema indicate robust ORM usage. The application communicates with a database through Prisma.
- Docker & Deployment Artifacts: Include Dockerfiles, docker-compose files (dev/prod), and environment configuration. These illustrate how the services are containerized and orchestrated.

##### Relationships and Interactions
- Clients send requests (HTTP/HTTPS) to the Nginx reverse proxy.
- Nginx routes these requests to the Next.js application container.
- The Next.js app processes requests using both its server-side rendered pages and API routes (for authentication, ticket creation, profile manipulation, etc.).
- For persistent storage, the app communicates with the database via Prisma ORM.
- Additionally, build and deployment pipelines (GitHub workflows, scripts like init-docker-dirs.sh, etc.) support CI/CD and container initialization.

##### Architectural Patterns & Design Principles
- Feature-Based / Domain-Driven Design: Notice clear separations between “entities”, “features”, and “shared” directories.
- Service/Repository Pattern: Within each entity, repositories and service layers define business logic and data abstraction.
- Containerization & Microservice-like isolation: Different containers for the web application and the Nginx reverse proxy, which can be scaled separately.

##### Relevant Technologies and Frameworks
- Next.js: For both SSR and API routes.
- Prisma: For database migrations, schema definition, and ORM functionalities.
- Docker & Docker Compose: For containerization and orchestration.
- Nginx: For reverse proxying and load balancing.
- Additional tooling such as ESLint, PostCSS, and Tailwind CSS (reference to tailwind.config.mjs).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Client Browser"]:::client
    end

    %% Reverse Proxy Layer
    subgraph "Reverse Proxy Layer"
        Nginx["Nginx Reverse Proxy"]:::proxy
    end

    %% Application Service Layer
    subgraph "Application Service Layer"
        NextApp["Next.js App Service"]:::next
        subgraph "Next.js Internal Structure"
            Pages["Frontend Pages (src/app)"]:::pages
            API["API Routes (src/app/api)"]:::api
        end
    end

    %% Domain Modules
    subgraph "Domain Modules"
        DomainEntities["Domain Entities (src/entities)"]:::domain
        SharedUI["Shared UI Components (src/shared/ui)"]:::shared
        Auth["Authentication Module (src/features/auth)"]:::feature
        Ticket["Ticket Creation Module (src/features/ticket/create)"]:::feature
    end

    %% Persistence & Deployment
    subgraph "Persistence & Deployment"
        DB["Database (via Prisma)"]:::db
        Deployment["Docker & Deployment Artifacts"]:::deployment
    end

    %% Data Flows
    Browser -->|"HTTP/HTTPS_request"| Nginx
    Nginx -->|"Routes_to"| NextApp
    NextApp -->|"Serves"| Pages
    NextApp -->|"Handles_API"| API
    NextApp -->|"Communicates_with"| DB
    Deployment -->|"Deploys_updates"| NextApp

    %% Click Events
    click Nginx "https://github.com/amirka2/unie/tree/dev/nginx"
    click NextApp "https://github.com/amirka2/unie/tree/dev/src/app"
    click API "https://github.com/amirka2/unie/tree/dev/src/app/api"
    click DB "https://github.com/amirka2/unie/tree/dev/prisma"
    click Deployment "https://github.com/amirka2/unie/tree/dev/Dockerfile"
    click DomainEntities "https://github.com/amirka2/unie/tree/dev/src/entities"
    click SharedUI "https://github.com/amirka2/unie/tree/dev/src/shared/ui"
    click Auth "https://github.com/amirka2/unie/tree/dev/src/features/auth"
    click Ticket "https://github.com/amirka2/unie/tree/dev/src/features/ticket/create"

    %% Styles
    classDef client fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef proxy fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef next fill:#A9DFBF,stroke:#239B56,stroke-width:2px;
    classDef pages fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
    classDef api fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
    classDef domain fill:#FAD7A0,stroke:#F39C12,stroke-width:2px;
    classDef shared fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
    classDef feature fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
    classDef db fill:#ABEBC6,stroke:#27AE60,stroke-width:2px;
    classDef deployment fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
```
