How shrinidhivittalar/bondgrid works
1. Overall shape
- bond_grid is an Nx monorepo with two runtime applications: a Next.js web client in apps/web and an Express API in apps/api.
- The key architectural boundary is clear: the web app handles interaction and visualization, while the API owns domain logic, persistence, and operational endpoints.
2. Frontend role
- The web app is organized as a graph-centric UI built around a main canvas and side panels.
- Primary UI pieces include GraphCanvas, ProfilePanel, AppSidebar, AppHeader, and modal flows for adding/editing people and relationships, plus merging records.
- This suggests a single-page, highly interactive experience rather than a traditional page-per-route site.
3. Frontend data flow
- The web app talks to the backend through src/services/apiClient.ts, so API access is centralized rather than scattered through components.
- Frontend domain types live in src/types/graph.ts, with supporting transformation logic in src/lib/graphUtils.ts.
- src/data/graphData.ts likely serves as local sample or bootstrap graph data for rendering and development.
4. Backend API surface
- The API is split by feature-oriented routes: people, relationships, graph, merge, activity, admin, and health.
- This indicates a REST-style service with separate endpoints for CRUD operations, graph views, merge operations, audit/activity lookup, administrative operations, and liveness checks.
5. Backend domain services
- Business logic is concentrated in src/services, especially personService, relationshipService, and graphSchemaService.
- Supporting services include consistencyService, auditService, idempotencyService, and metricsService, which point to a backend that does more than simple CRUD.
- The API therefore appears to enforce domain invariants and operational concerns before hitting persistence.
6. Persistence and graph model
- src/config/neo4j.ts and the docs references to Neo4j show that the core database is a Neo4j graph store.
- Data models in src/models/person.ts, relationship.ts, and relationshipTypes.ts imply the app stores people as nodes and relationships as typed edges.
- The main data boundary is between API services and Neo4j; the web app never appears to access the database directly.
7. Cross-cutting request handling
- authMiddleware.ts suggests protected endpoints or request authentication on the API side.
- idempotencyMiddleware.ts and idempotencyService.ts indicate some write operations are designed to be safely retried.
- auditService and metricsService show that writes and important actions are tracked for traceability and observability.
8. Graph-specific operations
- The presence of graph, merge, and consistency modules suggests the application supports non-trivial graph maintenance, not just simple entity editing.
- Merge flows are likely used to consolidate duplicate people or relationships, while consistency checks help keep the graph schema coherent.
- graphSchemaService probably defines allowed node/edge patterns and validation rules for the network model.
9. Operational endpoints
- health provides basic service status for local checks or deployment probes.
- admin and activity imply separate operational views or APIs for maintenance, auditing, and system inspection.
- These are distinct from end-user graph editing and should be shown in the architecture as administrative paths.
10. Repo-level tooling and boundaries
- Nx coordinates the monorepo, but the runtime boundary remains two deployable apps with independent startup commands.
- Shared code is minimal and mostly limited to repo-wide TypeScript, ESLint, and Prettier configuration rather than a shared business-logic package.
- For an architecture diagram, the central flow is: user/browser → Next.js UI → API client → Express routes → domain services → Neo4j, with auth/idempotency/audit/metrics wrapping the backend request path.
Main entry points: graph.ts API routes · page.tsx Web client · personService.ts Domain services · main.ts API server
Components 21
Web app
Next.js client for graph exploration and editing
- Web client · Interactive graph-focused browser app
apps/web/src/app/page.tsx - Graph canvas · Main graph interaction surface
apps/web/src/components/graph/GraphCanvas.tsx - Profile panel · Shows selected person details
apps/web/src/components/panels/ProfilePanel.tsx - Sidebar · Primary app navigation and controls
apps/web/src/components/sidebar/AppSidebar.tsx - Header · Top-level app header
apps/web/src/components/header/AppHeader.tsx - Edit flows · Add, edit, and merge record dialogs
apps/web/src/components/modals/AddPersonModal.tsx - API client · Centralized backend request layer
apps/web/src/services/apiClient.ts - Graph types · Frontend domain shape definitions
apps/web/src/types/graph.ts - Graph utils · Client-side graph transformation helpers
apps/web/src/lib/graphUtils.ts - Seed data · Local bootstrap graph data
apps/web/src/data/graphData.ts
API app
Express backend for domain logic and persistence
- API server · Backend application entrypoint
apps/api/src/main.ts - API routes · Feature-oriented HTTP endpoints
apps/api/src/routes/graph.ts - People routes · Person-oriented API surface
apps/api/src/routes/people.ts - Relationship routes · Relationship-oriented API surface
apps/api/src/routes/relationships.ts - Merge routes · Duplicate consolidation endpoints
apps/api/src/routes/merge.ts - Activity routes · Activity and history endpoints
apps/api/src/routes/activity.ts - Admin routes · Operational maintenance endpoints
apps/api/src/routes/admin.ts - Health check · Service liveness endpoint
apps/api/src/routes/health.ts - Middleware · Auth and idempotency protections
apps/api/src/middleware/authMiddleware.ts - Domain services · Core graph and entity operations
apps/api/src/services/personService.ts - Neo4j config · Database connection and graph persistence
apps/api/src/config/neo4j.ts
Connections 20
- Web client → Graph canvas: renders · Main interface centers on graph visualization
- Web client → Profile panel: shows · Selection opens detail panel
- Web client → Sidebar: contains · App shell navigation and controls
- Web client → Header: contains · Top chrome for the client
- Web client → Edit flows: opens · Editing and merge dialogs are launched from the UI
- Graph canvas → Graph utils: uses · Canvas relies on graph transformation helpers
- Web client → API client: calls · Client reads and writes through centralized API client
- API client → API server: targets · All backend requests terminate in the API app
- API server → Middleware: wraps · Request path is guarded before route handling
- API server → API routes: mounts · Entry point attaches feature routes
- API routes → People routes: includes · People CRUD surface
- API routes → Relationship routes: includes · Relationship CRUD surface
- API routes → Merge routes: includes · Merge workflow surface
- API routes → Activity routes: includes · Audit/activity surface
- API routes → Admin routes: includes · Operational admin surface
- API routes → Health check: includes · Service status endpoint
- People routes → Domain services: uses · Routes delegate domain logic to services
- Relationship routes → Domain services: uses · Routes delegate domain logic to services
- Merge routes → Domain services: uses · Merge operations reuse core services
- Domain services → Neo4j config: persists to · Domain services read and write Neo4j