# jagadishitwine/justiceflow architecture

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

- Interactive diagram: https://gitdiagram.com/jagadishitwine/justiceflow
- Repository: https://github.com/jagadishitwine/justiceflow

## Overview

JusticeFlow is a legal-practice management platform with an Angular attorney interface and separate client portal, backed by an Express API gateway and domain services. The main workflow is staff or client use of the frontend, gateway routing, domain operations, and MySQL persistence. Domain branches cover matters, clients and conflicts, documents and AI research, billing and retainers, time, and court calendars. README and the source index establish the overall architecture and several module dependencies; unsampled frontend API wiring and some service routes are not inferred as confirmed calls.

Main entry points: [`backend/api-gateway/routes.js`](https://github.com/jagadishitwine/justiceflow/blob/main/backend/api-gateway/routes.js) (API gateway), [`backend/database/db.js`](https://github.com/jagadishitwine/justiceflow/blob/main/backend/database/db.js) (MySQL database), [`backend/auth-service/controllers/auth.controller.js`](https://github.com/jagadishitwine/justiceflow/blob/main/backend/auth-service/controllers/auth.controller.js) (Authentication), [`backend/documents-service/controllers/document.controller.js`](https://github.com/jagadishitwine/justiceflow/blob/main/backend/documents-service/controllers/document.controller.js) (Documents and AI research)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_angular["Angular application<br/>[main.ts]"]
  node_routes["Application routes<br/>[app.routes.ts]"]
  node_staff_ui["Staff workspace"]
  node_portal_ui["Client portal"]
  node_api_client["API services<br/>[api.service.ts]"]
end

subgraph group_gateway["Gateway and security"]
  node_gateway["API gateway<br/>[routes.js]"]
  node_auth["Authentication<br/>[auth.controller.js]"]
  node_security["Auth middleware<br/>[authMiddleware.js]"]
end

subgraph group_legal["Legal operations"]
  node_clients["Client and conflicts"]
  node_cases["Cases and retainers<br/>[case.controller.js]"]
  node_documents["Documents and AI research"]
  node_rag["Case intelligence"]
  node_summarizer["Local summarizer"]
  node_billing["Invoices and trust"]
  node_calendar["Court calendar"]
  node_time["Time tracking"]
end

subgraph group_platform["Data and shared services"]
  node_db[("MySQL database<br/>[db.js]")]
  node_audit["Audit logging<br/>[audit.js]"]
  node_email["Email service<br/>[emailService.js]"]
end

node_staff(("Staff user"))
node_client(("Portal client"))

node_staff -->|"uses"| node_angular
node_client -->|"uses portal"| node_angular
node_angular -->|"loads routes"| node_routes
node_routes -->|"routes staff"| node_staff_ui
node_routes -->|"routes clients"| node_portal_ui
node_angular -.->|"uses API"| node_api_client
node_api_client -->|"sends HTTP JSON"| node_gateway
node_gateway -->|"routes auth"| node_auth
node_gateway -->|"routes clients"| node_clients
node_gateway -->|"routes cases"| node_cases
node_gateway -->|"routes documents"| node_documents
node_gateway -->|"routes time"| node_time
node_gateway -.->|"routes billing"| node_billing
node_gateway -.->|"routes calendar"| node_calendar
node_auth -->|"uses token secret"| node_security
node_auth -->|"reads and writes"| node_db
node_clients -->|"persists records"| node_db
node_cases -->|"persists records"| node_db
node_documents -->|"invokes analysis"| node_rag
node_documents -->|"uses summarizer"| node_summarizer
node_rag -->|"processes text"| node_summarizer
node_documents -->|"stores metadata"| node_db
node_rag -->|"queries case data"| node_db
node_billing -->|"persists billing"| node_db
node_calendar -->|"persists events"| node_db
node_time -->|"persists entries"| node_db
node_auth -->|"records actions"| node_audit
node_billing -->|"records actions"| node_audit
node_time -->|"records actions"| node_audit
node_clients -->|"sends email"| node_email
node_audit -->|"writes audit logs"| node_db

click node_angular "https://github.com/jagadishitwine/justiceflow/blob/main/frontend/src/main.ts"
click node_routes "https://github.com/jagadishitwine/justiceflow/blob/main/frontend/src/app/app.routes.ts"
click node_staff_ui "https://github.com/jagadishitwine/justiceflow/blob/main/frontend/src/app/pages/dashboard/dashboard.component.ts"
click node_portal_ui "https://github.com/jagadishitwine/justiceflow/blob/main/frontend/src/app/pages/portal/portal-dashboard.component.ts"
click node_api_client "https://github.com/jagadishitwine/justiceflow/blob/main/frontend/src/app/core/services/api.service.ts"
click node_gateway "https://github.com/jagadishitwine/justiceflow/blob/main/backend/api-gateway/routes.js"
click node_auth "https://github.com/jagadishitwine/justiceflow/blob/main/backend/auth-service/controllers/auth.controller.js"
click node_security "https://github.com/jagadishitwine/justiceflow/blob/main/backend/shared/authMiddleware.js"
click node_clients "https://github.com/jagadishitwine/justiceflow/blob/main/backend/client-service/controllers/client.controller.js"
click node_cases "https://github.com/jagadishitwine/justiceflow/blob/main/backend/case-service/controllers/case.controller.js"
click node_documents "https://github.com/jagadishitwine/justiceflow/blob/main/backend/documents-service/controllers/document.controller.js"
click node_rag "https://github.com/jagadishitwine/justiceflow/blob/main/backend/documents-service/services/case-rag.service.js"
click node_summarizer "https://github.com/jagadishitwine/justiceflow/blob/main/backend/documents-service/services/local-summarizer.service.js"
click node_billing "https://github.com/jagadishitwine/justiceflow/blob/main/backend/billing-service/controllers/billing.controller.js"
click node_calendar "https://github.com/jagadishitwine/justiceflow/blob/main/backend/calendar-service/controllers/calendar.controller.js"
click node_time "https://github.com/jagadishitwine/justiceflow/blob/main/backend/time-tracking-service/controllers/time-entry.controller.js"
click node_db "https://github.com/jagadishitwine/justiceflow/blob/main/backend/database/db.js"
click node_audit "https://github.com/jagadishitwine/justiceflow/blob/main/backend/shared/audit.js"
click node_email "https://github.com/jagadishitwine/justiceflow/blob/main/backend/shared/emailService.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_angular,node_routes,node_staff_ui,node_portal_ui,node_api_client,node_staff,node_client toneBlue
class node_gateway,node_auth,node_security toneAmber
class node_clients,node_cases,node_documents,node_rag,node_summarizer,node_billing,node_calendar,node_time toneMint
class node_db,node_audit,node_email toneRose
```

## Components

### Frontend

- [Angular application](https://github.com/jagadishitwine/justiceflow/blob/main/frontend/src/main.ts): `frontend/src/main.ts`
- [Application routes](https://github.com/jagadishitwine/justiceflow/blob/main/frontend/src/app/app.routes.ts): `frontend/src/app/app.routes.ts`
- [Staff workspace](https://github.com/jagadishitwine/justiceflow/blob/main/frontend/src/app/pages/dashboard/dashboard.component.ts): `frontend/src/app/pages/dashboard/dashboard.component.ts`
- [Client portal](https://github.com/jagadishitwine/justiceflow/blob/main/frontend/src/app/pages/portal/portal-dashboard.component.ts): `frontend/src/app/pages/portal/portal-dashboard.component.ts`
- [API services](https://github.com/jagadishitwine/justiceflow/blob/main/frontend/src/app/core/services/api.service.ts): `frontend/src/app/core/services/api.service.ts`

### Gateway and security

- [API gateway](https://github.com/jagadishitwine/justiceflow/blob/main/backend/api-gateway/routes.js): `backend/api-gateway/routes.js`
- [Authentication](https://github.com/jagadishitwine/justiceflow/blob/main/backend/auth-service/controllers/auth.controller.js): `backend/auth-service/controllers/auth.controller.js`
- [Auth middleware](https://github.com/jagadishitwine/justiceflow/blob/main/backend/shared/authMiddleware.js): `backend/shared/authMiddleware.js`

### Legal operations

- [Client and conflicts](https://github.com/jagadishitwine/justiceflow/blob/main/backend/client-service/controllers/client.controller.js): `backend/client-service/controllers/client.controller.js`
- [Cases and retainers](https://github.com/jagadishitwine/justiceflow/blob/main/backend/case-service/controllers/case.controller.js): `backend/case-service/controllers/case.controller.js`
- [Documents and AI research](https://github.com/jagadishitwine/justiceflow/blob/main/backend/documents-service/controllers/document.controller.js): `backend/documents-service/controllers/document.controller.js`
- [Case intelligence](https://github.com/jagadishitwine/justiceflow/blob/main/backend/documents-service/services/case-rag.service.js): `backend/documents-service/services/case-rag.service.js`
- [Local summarizer](https://github.com/jagadishitwine/justiceflow/blob/main/backend/documents-service/services/local-summarizer.service.js): `backend/documents-service/services/local-summarizer.service.js`
- [Invoices and trust](https://github.com/jagadishitwine/justiceflow/blob/main/backend/billing-service/controllers/billing.controller.js): `backend/billing-service/controllers/billing.controller.js`
- [Court calendar](https://github.com/jagadishitwine/justiceflow/blob/main/backend/calendar-service/controllers/calendar.controller.js): `backend/calendar-service/controllers/calendar.controller.js`
- [Time tracking](https://github.com/jagadishitwine/justiceflow/blob/main/backend/time-tracking-service/controllers/time-entry.controller.js): `backend/time-tracking-service/controllers/time-entry.controller.js`

### Data and shared services

- [MySQL database](https://github.com/jagadishitwine/justiceflow/blob/main/backend/database/db.js): `backend/database/db.js`
- [Audit logging](https://github.com/jagadishitwine/justiceflow/blob/main/backend/shared/audit.js): `backend/shared/audit.js`
- [Email service](https://github.com/jagadishitwine/justiceflow/blob/main/backend/shared/emailService.js): `backend/shared/emailService.js`

### Other components

- **Staff user**
- **Portal client**

## Connections

- Staff user → Angular application: uses
- Portal client → Angular application: uses portal
- Angular application → Application routes: loads routes (evidence: `frontend/src/app/app.routes.ts`)
- Application routes → Staff workspace: routes staff (evidence: `frontend/src/app/app.routes.ts`)
- Application routes → Client portal: routes clients (evidence: `frontend/src/app/app.routes.ts`)
- Angular application → API services: uses API
- API services → API gateway: sends HTTP JSON
- API gateway → Authentication: routes auth
- API gateway → Client and conflicts: routes clients
- API gateway → Cases and retainers: routes cases
- API gateway → Documents and AI research: routes documents
- API gateway → Time tracking: routes time
- API gateway → Invoices and trust: routes billing
- API gateway → Court calendar: routes calendar
- Authentication → Auth middleware: uses token secret (evidence: `backend/auth-service/controllers/auth.controller.js`)
- Authentication → MySQL database: reads and writes
- Client and conflicts → MySQL database: persists records
- Cases and retainers → MySQL database: persists records
- Documents and AI research → Case intelligence: invokes analysis (evidence: `backend/documents-service/controllers/document.controller.js`)
- Documents and AI research → Local summarizer: uses summarizer (evidence: `backend/documents-service/controllers/document.controller.js`)
- Case intelligence → Local summarizer: processes text (evidence: `backend/documents-service/services/case-rag.service.js`)
- Documents and AI research → MySQL database: stores metadata
- Case intelligence → MySQL database: queries case data (evidence: `backend/documents-service/services/case-rag.service.js`)
- Invoices and trust → MySQL database: persists billing
- Court calendar → MySQL database: persists events
- Time tracking → MySQL database: persists entries
- Authentication → Audit logging: records actions (evidence: `backend/auth-service/controllers/auth.controller.js`)
- Invoices and trust → Audit logging: records actions (evidence: `backend/billing-service/controllers/billing.controller.js`)
- Time tracking → Audit logging: records actions (evidence: `backend/time-tracking-service/controllers/time-entry.controller.js`)
- Client and conflicts → Email service: sends email (evidence: `backend/client-service/controllers/client.controller.js`)
- Audit logging → MySQL database: writes audit logs (evidence: `backend/shared/audit.js`)
