# combiao/finlover architecture

> Architecture diagram of the GitHub repository combiao/finlover, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/combiao/finlover
- Repository: https://github.com/combiao/finlover

## Overview

#### Purpose and Runtime
FinLover is an expense-tracker foundation built as a single Next.js App Router application. It uses TypeScript, Tailwind CSS, MongoDB/Mongoose persistence, and bcrypt/JWT-based authentication. The application is run with npm and serves locally through Next.js.

Key runtime/configuration paths: `package.json`, `next.config.ts`, `.env.example`.

#### Application Entry and Shell
The App Router owns application bootstrapping and page rendering. The root layout establishes shared document/UI structure and global styles; the root page is the current primary user-facing entry point.

Paths: `src/app/layout.tsx`, `src/app/page.tsx`, `src/app/globals.css`.

#### API Boundary
Server-side HTTP endpoints belong under the App Router API namespace. The directory exists but contains no implemented routes yet, making it the intended boundary for authentication, expense operations, and other client/server interactions.

Paths: `src/app/api`, `src/app/api/.gitkeep`.

#### Authentication Layer
Authentication is centralized in a library module and is intended to combine JWT token handling with bcrypt password hashing. Secrets and hashing cost are supplied through environment variables rather than source control.

Paths: `src/lib/auth.ts`, `.env.example`, `src/app/api`.

#### Persistence Layer
MongoDB access is encapsulated behind a database library module, with Mongoose identified as the ODM. Domain schemas/models are intended to live separately from connection logic, preserving a boundary between infrastructure and expense/user entities.

Paths: `src/lib/db.ts`, `src/models`, `.env.example`.

#### UI Composition
Reusable application components are separated from the route tree. The repository includes a shared UI button primitive and a reserved area for higher-level feature components; Tailwind/PostCSS provide styling infrastructure.

Paths: `src/components/ui/button.tsx`, `src/components`, `components.json`.

#### Shared Client/Server Utilities and Types
Cross-cutting helpers are collected in `src/lib`, while hooks and TypeScript domain contracts have dedicated extension points. This supports keeping route code focused on orchestration rather than shared behavior or data definitions.

Paths: `src/lib/utils.ts`, `src/hooks`, `src/types`.

#### Delivery Controls
GitHub Actions provides CI, while Husky hooks and repository scripts enforce branch and commit-message conventions before changes enter the main workflow.

Paths: `.github/workflows/ci.yml`, `.husky/pre-commit`, `scripts/check-branch-name.js`.

Main entry points: [`src/app/page.tsx`](https://github.com/combiao/finlover/blob/main/src/app/page.tsx) (Root page), [`src/app/api`](https://github.com/combiao/finlover/tree/main/src/app/api) (API namespace), [`src/app/layout.tsx`](https://github.com/combiao/finlover/blob/main/src/app/layout.tsx) (Root layout), [`src/lib/db.ts`](https://github.com/combiao/finlover/blob/main/src/lib/db.ts) (Database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Next.js application"]
  node_next["Next.js config<br/>framework config<br/>[next.config.ts]"]
  node_layout["Root layout<br/>App Router shell<br/>[layout.tsx]"]
  node_page["Root page<br/>route page<br/>[page.tsx]"]
  node_styles["Global styles<br/>CSS<br/>[globals.css]"]
end

subgraph group_server["Server boundary"]
  node_api["API namespace<br/>App Router endpoints"]
  node_auth["Authentication<br/>JWT and bcrypt<br/>[auth.ts]"]
  node_db[("Database access<br/>Mongoose connection<br/>[db.ts]")]
  node_models["Domain models<br/>Mongoose schemas"]
  node_environment["Environment variables<br/>secrets and settings<br/>[.env.example]"]
end

subgraph group_shared["Shared code"]
  node_components["Component library<br/>reusable UI"]
  node_button["Button primitive<br/>UI component<br/>[button.tsx]"]
  node_utilities["Shared utilities<br/>cross-cutting helpers<br/>[utils.ts]"]
  node_hooks["Hooks extension point<br/>client hooks"]
  node_types["Type contracts<br/>TypeScript types"]
end

subgraph group_delivery["Delivery controls"]
  node_ci["CI workflow<br/>GitHub Actions<br/>[ci.yml]"]
  node_precommit["Pre-commit hook<br/>Husky hook<br/>[pre-commit]"]
  node_branchcheck["Branch-name check<br/>repository script"]
end

node_package["npm runtime<br/>package scripts<br/>[package.json]"]

node_package -->|"configures"| node_next
node_next -->|"boots App Router"| node_layout
node_layout -->|"renders"| node_page
node_layout -->|"loads"| node_styles
node_page -->|"composes"| node_components
node_components -->|"includes"| node_button
node_page -.->|"uses"| node_hooks
node_page -.->|"uses contracts"| node_types
node_api -.->|"will authenticate through"| node_auth
node_api -.->|"will persist through"| node_db
node_db -.->|"loads schemas"| node_models
node_auth -->|"reads secrets and cost"| node_environment
node_db -->|"reads MongoDB settings"| node_environment
node_api -.->|"uses contracts"| node_types
node_utilities -.->|"uses contracts"| node_types
node_ci -->|"runs checks"| node_package
node_precommit -->|"executes"| node_branchcheck

click node_package "https://github.com/combiao/finlover/blob/main/package.json"
click node_next "https://github.com/combiao/finlover/blob/main/next.config.ts"
click node_layout "https://github.com/combiao/finlover/blob/main/src/app/layout.tsx"
click node_page "https://github.com/combiao/finlover/blob/main/src/app/page.tsx"
click node_styles "https://github.com/combiao/finlover/blob/main/src/app/globals.css"
click node_api "https://github.com/combiao/finlover/tree/main/src/app/api"
click node_auth "https://github.com/combiao/finlover/blob/main/src/lib/auth.ts"
click node_db "https://github.com/combiao/finlover/blob/main/src/lib/db.ts"
click node_models "https://github.com/combiao/finlover/tree/main/src/models"
click node_components "https://github.com/combiao/finlover/tree/main/src/components"
click node_button "https://github.com/combiao/finlover/blob/main/src/components/ui/button.tsx"
click node_utilities "https://github.com/combiao/finlover/blob/main/src/lib/utils.ts"
click node_hooks "https://github.com/combiao/finlover/tree/main/src/hooks"
click node_types "https://github.com/combiao/finlover/tree/main/src/types"
click node_environment "https://github.com/combiao/finlover/blob/main/.env.example"
click node_ci "https://github.com/combiao/finlover/blob/main/.github/workflows/ci.yml"
click node_precommit "https://github.com/combiao/finlover/blob/main/.husky/pre-commit"
click node_branchcheck "https://github.com/combiao/finlover/blob/main/scripts/check-branch-name.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_next,node_layout,node_page,node_styles toneBlue
class node_api,node_auth,node_db,node_models,node_environment toneAmber
class node_components,node_button,node_utilities,node_hooks,node_types toneMint
class node_ci,node_precommit,node_branchcheck toneRose
class node_package toneNeutral
```

## Components

### Next.js application

- [Next.js config](https://github.com/combiao/finlover/blob/main/next.config.ts): framework config · `next.config.ts`
- [Root layout](https://github.com/combiao/finlover/blob/main/src/app/layout.tsx): App Router shell · Establishes shared document structure and global UI. · `src/app/layout.tsx`
- [Root page](https://github.com/combiao/finlover/blob/main/src/app/page.tsx): route page · Current primary user-facing entry point. · `src/app/page.tsx`
- [Global styles](https://github.com/combiao/finlover/blob/main/src/app/globals.css): CSS · `src/app/globals.css`

### Server boundary

- [API namespace](https://github.com/combiao/finlover/tree/main/src/app/api): App Router endpoints · Reserved HTTP boundary for auth and expense operations. · `src/app/api`
- [Authentication](https://github.com/combiao/finlover/blob/main/src/lib/auth.ts): JWT and bcrypt · Centralizes token handling and password hashing. · `src/lib/auth.ts`
- [Database access](https://github.com/combiao/finlover/blob/main/src/lib/db.ts): Mongoose connection · Encapsulates MongoDB connection infrastructure. · `src/lib/db.ts`
- [Domain models](https://github.com/combiao/finlover/tree/main/src/models): Mongoose schemas · Reserved boundary for user and expense entities. · `src/models`
- [Environment variables](https://github.com/combiao/finlover/blob/main/.env.example): secrets and settings · Supplies database, JWT, and hashing configuration. · `.env.example`

### Shared code

- [Component library](https://github.com/combiao/finlover/tree/main/src/components): reusable UI · Shared primitives and feature component extension point. · `src/components`
- [Button primitive](https://github.com/combiao/finlover/blob/main/src/components/ui/button.tsx): UI component · `src/components/ui/button.tsx`
- [Shared utilities](https://github.com/combiao/finlover/blob/main/src/lib/utils.ts): cross-cutting helpers · `src/lib/utils.ts`
- [Hooks extension point](https://github.com/combiao/finlover/tree/main/src/hooks): client hooks · `src/hooks`
- [Type contracts](https://github.com/combiao/finlover/tree/main/src/types): TypeScript types · `src/types`

### Delivery controls

- [CI workflow](https://github.com/combiao/finlover/blob/main/.github/workflows/ci.yml): GitHub Actions · `.github/workflows/ci.yml`
- [Pre-commit hook](https://github.com/combiao/finlover/blob/main/.husky/pre-commit): Husky hook · Enforces branch naming before changes enter the workflow. · `.husky/pre-commit`
- [Branch-name check](https://github.com/combiao/finlover/blob/main/scripts/check-branch-name.js): repository script · `scripts/check-branch-name.js`

### Other components

- [npm runtime](https://github.com/combiao/finlover/blob/main/package.json): package scripts · Runs the Next.js application. · `package.json`

## Connections

- npm runtime → Next.js config: configures
- Next.js config → Root layout: boots App Router
- Root layout → Root page: renders
- Root layout → Global styles: loads
- Root page → Component library: composes
- Component library → Button primitive: includes
- Root page → Hooks extension point: uses
- Root page → Type contracts: uses contracts
- API namespace → Authentication: will authenticate through
- API namespace → Database access: will persist through
- Database access → Domain models: loads schemas
- Authentication → Environment variables: reads secrets and cost
- Database access → Environment variables: reads MongoDB settings
- API namespace → Type contracts: uses contracts
- Shared utilities → Type contracts: uses contracts
- CI workflow → npm runtime: runs checks
- Pre-commit hook → Branch-name check: executes
