# aldowadsimanjuntak/banking-system architecture

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

- Interactive diagram: https://gitdiagram.com/aldowadsimanjuntak/banking-system
- Repository: https://github.com/aldowadsimanjuntak/banking-system

## Overview

##### Project Type and Purpose
- This is a full-stack banking system application.
- Frontend: Next.js (React) with TypeScript, Tailwind CSS, Axios.
- Backend: Express.js + Node.js, exposing RESTful endpoints for users, bank accounts, transactions, authentication, and media.
- Database: PostgreSQL accessed via Prisma ORM.
- Email service via Nodemailer, file uploads via Multer/imagekit, logging (Morgan), error tracking (Sentry), and API docs via Swagger/OpenAPI.

##### File Structure
- Top level:
- api/ – Express route handlers (BankAccount.js, Transaction.js, User.js, auth.js, media.js)
- controllers/ – Business logic separated from routes
- utils/ – Authentication helpers, JWT, file-upload, imagekit, middleware (require.login)
- nodemailer/ – Email templates and mailing code
- prisma/ – Schema and migrations for PostgreSQL
- router.js & index.js – Express app entrypoint and route registration
- openapi.json – Swagger spec for API docs
- tests/ & coverage/ – Jest test suites for controllers and endpoints
- banking-system-frontend/ – Next.js app with app-directory, services/api.ts, utils/auth.ts, pages for login/register/dashboard
- Patterns:
- Backend follows a layered MVC-style separation: routes (api/), controllers, utils/services.
- Frontend is organized per Next.js 14 conventions (app router, layout, page.tsx files, middleware for protected routes).

##### README for Additional Insights
- Tech stack section confirms frameworks and services.
- “Features” section highlights core modules (auth, accounts, transactions, dashboard).
- Running instructions reveal two servers: backend on port 3000, frontend on 3001.
- API docs accessible at /docs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    Client["User (Browser/Mobile)"]:::frontend
    FrontendApp["Next.js App"]:::frontend
    AuthUtils["Auth Utils & Middleware"]:::frontend
    APIService["API Service Module"]:::frontend

    Client -->|"HTTP(S) Requests"| FrontendApp
    FrontendApp -->|"uses"| AuthUtils
    FrontendApp -->|"calls"| APIService

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        ExpressAPI["Express.js API"]:::service
        Router["API Gateway (router.js)"]:::service
        subgraph "API Layer"
            direction TB
            BA["BankAccount.js"]:::service
            TR["Transaction.js"]:::service
            USR["User.js"]:::service
            AUTH["auth.js"]:::service
            MED["media.js"]:::service
        end
        subgraph "Controller Layer"
            direction TB
            Ctrl["nasabahController.js"]:::service
        end
        subgraph "Utils & Services"
            direction TB
            AuthUtilsBE["auth.js / jwt.js / require.login.js"]:::service
            MediaUtils["multer.js / imagekit.js"]:::service
            EmailService["Nodemailer Service"]:::service
            Sentry["Error Tracking (Sentry)"]:::external
            Swagger["Swagger UI (openapi.json)"]:::external
        end
        subgraph "Data Layer"
            direction TB
            Prisma["Prisma ORM"]:::service
            DB["PostgreSQL DB"]:::database
        end

        ExpressAPI -->|"registers routes"| Router
        Router -->|"routes to handlers"| BA
        Router --> TR
        Router --> USR
        Router --> AUTH
        Router --> MED

        BA -->|"calls"| Ctrl
        TR --> Ctrl
        USR --> Ctrl
        AUTH --> Ctrl
        MED --> Ctrl

        Ctrl -->|"uses"| AuthUtilsBE
        Ctrl -->|"uses"| MediaUtils
        Ctrl -->|"invokes"| EmailService
        Ctrl -->|"queries"| Prisma
        Prisma -->|"reads/writes"| DB

        ExpressAPI -->|".use(morgan, CORS, etc.)"| Sentry
        ExpressAPI -->|"serves docs"| Swagger
    end

    %% External Services
    EmailService -.->|"SMTP"| SMTP["SMTP Relay"]:::external
    MediaUtils -.->|"uploads"| Storage["ImageKit/Local Storage"]:::service

    %% Click Events
    click FrontendApp "https://github.com/aldowadsimanjuntak/banking-system/tree/main/banking-system-frontend/"
    click APIService "https://github.com/aldowadsimanjuntak/banking-system/blob/main/banking-system-frontend/src/services/api.ts"
    click AuthUtils "https://github.com/aldowadsimanjuntak/banking-system/blob/main/banking-system-frontend/src/utils/auth.ts"
    click AuthUtils "https://github.com/aldowadsimanjuntak/banking-system/blob/main/banking-system-frontend/src/middleware.ts"
    click Router "https://github.com/aldowadsimanjuntak/banking-system/blob/main/router.js"
    click BA "https://github.com/aldowadsimanjuntak/banking-system/blob/main/api/BankAccount.js"
    click TR "https://github.com/aldowadsimanjuntak/banking-system/blob/main/api/Transaction.js"
    click USR "https://github.com/aldowadsimanjuntak/banking-system/blob/main/api/User.js"
    click AUTH "https://github.com/aldowadsimanjuntak/banking-system/blob/main/api/auth.js"
    click MED "https://github.com/aldowadsimanjuntak/banking-system/blob/main/api/media.js"
    click Ctrl "https://github.com/aldowadsimanjuntak/banking-system/blob/main/controllers/nasabahController.js"
    click AuthUtilsBE "https://github.com/aldowadsimanjuntak/banking-system/blob/main/utils/auth.js"
    click AuthUtilsBE "https://github.com/aldowadsimanjuntak/banking-system/blob/main/utils/jwt.js"
    click AuthUtilsBE "https://github.com/aldowadsimanjuntak/banking-system/blob/main/utils/require.login.js"
    click MediaUtils "https://github.com/aldowadsimanjuntak/banking-system/blob/main/utils/multer.js"
    click MediaUtils "https://github.com/aldowadsimanjuntak/banking-system/blob/main/utils/imagekit.js"
    click EmailService "https://github.com/aldowadsimanjuntak/banking-system/blob/main/nodemailer/mailer.js"
    click EmailService "https://github.com/aldowadsimanjuntak/banking-system/blob/main/nodemailer/sendmail.js"
    click EmailService "https://github.com/aldowadsimanjuntak/banking-system/blob/main/nodemailer/mail.ejs"
    click Prisma "https://github.com/aldowadsimanjuntak/banking-system/blob/main/prisma/schema.prisma"
    click Prisma "https://github.com/aldowadsimanjuntak/banking-system/tree/main/prisma/migrations/"
    click Swagger "https://github.com/aldowadsimanjuntak/banking-system/blob/main/openapi.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef service fill:#DFF8D0,stroke:#28a745,color:#155724
    classDef database fill:#FFF3BF,stroke:#d6a700,color:#8c6d00
    classDef external fill:#E8E8E8,stroke:#6c757d,color:#343a40
```
