# chiru-5/lawezy architecture

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

- Interactive diagram: https://gitdiagram.com/chiru-5/lawezy
- Repository: https://github.com/chiru-5/lawezy

## Overview

LawEzy is a legal-services platform whose main user journey is to find an advocate, book a consultation, and manage it alongside legal information and support features. The graph also covers account management, AI consultation, blogs, downloadable resources, and direct messaging. The README documents several capabilities whose page or runtime wiring was not sampled; those relationships are marked dashed when not directly evidenced. API-to-model and connection edges are supported by the indexed route references and route excerpts.

Main entry points: [`lib/mongodb.js`](https://github.com/chiru-5/lawezy/blob/main/lib/mongodb.js) (MongoDB Connection), [`lib/auth-provider.jsx`](https://github.com/chiru-5/lawezy/blob/main/lib/auth-provider.jsx) (Session Provider), [`app/api/appointments/route.js`](https://github.com/chiru-5/lawezy/blob/main/app/api/appointments/route.js) (Appointment API), [`app/api/auth/register/route.js`](https://github.com/chiru-5/lawezy/blob/main/app/api/auth/register/route.js) (Authentication API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Accounts &amp; Profiles"]
  node_authui["Account Pages<br/>[page.jsx]"]
  node_auth["Session Provider<br/>[auth-provider.jsx]"]
  node_profile["Profile Editor<br/>[page.jsx]"]
  node_userapi["Advocate API<br/>[route.js]"]
  node_authapi["Authentication API<br/>[route.js]"]
  node_loginapi["Login API<br/>[route.js]"]
end

subgraph group_consult["Legal Consultations"]
  node_advocates["Advocate Directory<br/>[page.jsx]"]
  node_booking["Appointment Booking<br/>[page.jsx]"]
  node_appointmentapi["Appointment API<br/>[route.js]"]
  node_messaging["Direct Messaging<br/>[page.jsx]"]
end

subgraph group_knowledge["Legal Knowledge"]
  node_aiui["AI Consultation UI<br/>[page.jsx]"]
  node_gemini["Legal AI Engine<br/>[gemini.js]"]
  node_blogs["Legal Blogs<br/>[page.jsx]"]
  node_blogapi["Blog API<br/>[route.js]"]
  node_resources["Legal Resources<br/>[page.jsx]"]
  node_resourceapi["Resource API<br/>[route.js]"]
end

subgraph group_platform["Platform Data"]
  node_users["User Model<br/>[User.js]"]
  node_appointments["Appointment Model<br/>[Appointment.js]"]
  node_blogmodel["Blog Model<br/>[Blog.js]"]
  node_resourcemodel["Resource Model<br/>[Resource.js]"]
  node_messagesmodel["Message Model<br/>[Message.js]"]
  node_database[("MongoDB Connection<br/>[mongodb.js]")]
end

node_citizen(("Citizen"))
node_advocate(("Advocate"))

node_citizen -.->|"creates account"| node_authui
node_authui -->|"submits credentials"| node_auth
node_auth -->|"registers account"| node_authapi
node_auth -->|"authenticates"| node_loginapi
node_profile -->|"updates profile"| node_auth
node_citizen -.->|"finds advocate"| node_advocates
node_advocates -->|"opens booking"| node_booking
node_citizen -.->|"requests consultation"| node_booking
node_advocate -.->|"manages bookings"| node_appointmentapi
node_booking -.->|"submits booking"| node_appointmentapi
node_appointmentapi -->|"uses model"| node_appointments
node_appointmentapi -->|"connects"| node_database
node_citizen -.->|"asks legal question"| node_aiui
node_aiui -->|"requests response"| node_gemini
node_citizen -.->|"reads articles"| node_blogs
node_blogs -.->|"loads articles"| node_blogapi
node_blogapi -->|"uses model"| node_blogmodel
node_blogapi -->|"connects"| node_database
node_citizen -.->|"browses templates"| node_resources
node_resources -.->|"loads resources"| node_resourceapi
node_resourceapi -->|"uses model"| node_resourcemodel
node_resourceapi -->|"connects"| node_database
node_citizen -.->|"messages advocate"| node_messaging
node_messaging -.->|"stores conversations"| node_messagesmodel
node_userapi -->|"uses model"| node_users
node_userapi -->|"connects"| node_database
node_authapi -->|"uses model"| node_users
node_authapi -->|"connects"| node_database
node_loginapi -->|"uses model"| node_users
node_loginapi -->|"connects"| node_database
node_advocate -.->|"listed in directory"| node_userapi

click node_authui "https://github.com/chiru-5/lawezy/blob/main/app/signup/page.jsx"
click node_auth "https://github.com/chiru-5/lawezy/blob/main/lib/auth-provider.jsx"
click node_profile "https://github.com/chiru-5/lawezy/blob/main/app/profile/page.jsx"
click node_advocates "https://github.com/chiru-5/lawezy/blob/main/app/appointments/page.jsx"
click node_booking "https://github.com/chiru-5/lawezy/blob/main/app/appointments/book/%5Bid%5D/page.jsx"
click node_appointmentapi "https://github.com/chiru-5/lawezy/blob/main/app/api/appointments/route.js"
click node_messaging "https://github.com/chiru-5/lawezy/blob/main/app/chat/%5Bid%5D/page.jsx"
click node_aiui "https://github.com/chiru-5/lawezy/blob/main/app/ai-chat/page.jsx"
click node_gemini "https://github.com/chiru-5/lawezy/blob/main/lib/gemini.js"
click node_blogs "https://github.com/chiru-5/lawezy/blob/main/app/blogs/page.jsx"
click node_blogapi "https://github.com/chiru-5/lawezy/blob/main/app/api/blogs/route.js"
click node_resources "https://github.com/chiru-5/lawezy/blob/main/app/resources/page.jsx"
click node_resourceapi "https://github.com/chiru-5/lawezy/blob/main/app/api/resources/route.js"
click node_userapi "https://github.com/chiru-5/lawezy/blob/main/app/api/users/route.js"
click node_authapi "https://github.com/chiru-5/lawezy/blob/main/app/api/auth/register/route.js"
click node_loginapi "https://github.com/chiru-5/lawezy/blob/main/app/api/auth/login/route.js"
click node_users "https://github.com/chiru-5/lawezy/blob/main/models/User.js"
click node_appointments "https://github.com/chiru-5/lawezy/blob/main/models/Appointment.js"
click node_blogmodel "https://github.com/chiru-5/lawezy/blob/main/models/Blog.js"
click node_resourcemodel "https://github.com/chiru-5/lawezy/blob/main/models/Resource.js"
click node_messagesmodel "https://github.com/chiru-5/lawezy/blob/main/models/Message.js"
click node_database "https://github.com/chiru-5/lawezy/blob/main/lib/mongodb.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_authui,node_auth,node_profile,node_userapi,node_authapi,node_loginapi toneBlue
class node_advocates,node_booking,node_appointmentapi,node_messaging toneAmber
class node_aiui,node_gemini,node_blogs,node_blogapi,node_resources,node_resourceapi toneMint
class node_users,node_appointments,node_blogmodel,node_resourcemodel,node_messagesmodel,node_database toneRose
class node_citizen,node_advocate toneIndigo
```

## Components

### Accounts & Profiles

- [Account Pages](https://github.com/chiru-5/lawezy/blob/main/app/signup/page.jsx): `app/signup/page.jsx`
- [Session Provider](https://github.com/chiru-5/lawezy/blob/main/lib/auth-provider.jsx): `lib/auth-provider.jsx`
- [Profile Editor](https://github.com/chiru-5/lawezy/blob/main/app/profile/page.jsx): `app/profile/page.jsx`
- [Advocate API](https://github.com/chiru-5/lawezy/blob/main/app/api/users/route.js): `app/api/users/route.js`
- [Authentication API](https://github.com/chiru-5/lawezy/blob/main/app/api/auth/register/route.js): `app/api/auth/register/route.js`
- [Login API](https://github.com/chiru-5/lawezy/blob/main/app/api/auth/login/route.js): `app/api/auth/login/route.js`

### Legal Consultations

- [Advocate Directory](https://github.com/chiru-5/lawezy/blob/main/app/appointments/page.jsx): `app/appointments/page.jsx`
- [Appointment Booking](https://github.com/chiru-5/lawezy/blob/main/app/appointments/book/%5Bid%5D/page.jsx): `app/appointments/book/[id]/page.jsx`
- [Appointment API](https://github.com/chiru-5/lawezy/blob/main/app/api/appointments/route.js): `app/api/appointments/route.js`
- [Direct Messaging](https://github.com/chiru-5/lawezy/blob/main/app/chat/%5Bid%5D/page.jsx): `app/chat/[id]/page.jsx`

### Legal Knowledge

- [AI Consultation UI](https://github.com/chiru-5/lawezy/blob/main/app/ai-chat/page.jsx): `app/ai-chat/page.jsx`
- [Legal AI Engine](https://github.com/chiru-5/lawezy/blob/main/lib/gemini.js): `lib/gemini.js`
- [Legal Blogs](https://github.com/chiru-5/lawezy/blob/main/app/blogs/page.jsx): `app/blogs/page.jsx`
- [Blog API](https://github.com/chiru-5/lawezy/blob/main/app/api/blogs/route.js): `app/api/blogs/route.js`
- [Legal Resources](https://github.com/chiru-5/lawezy/blob/main/app/resources/page.jsx): `app/resources/page.jsx`
- [Resource API](https://github.com/chiru-5/lawezy/blob/main/app/api/resources/route.js): `app/api/resources/route.js`

### Platform Data

- [User Model](https://github.com/chiru-5/lawezy/blob/main/models/User.js): `models/User.js`
- [Appointment Model](https://github.com/chiru-5/lawezy/blob/main/models/Appointment.js): `models/Appointment.js`
- [Blog Model](https://github.com/chiru-5/lawezy/blob/main/models/Blog.js): `models/Blog.js`
- [Resource Model](https://github.com/chiru-5/lawezy/blob/main/models/Resource.js): `models/Resource.js`
- [Message Model](https://github.com/chiru-5/lawezy/blob/main/models/Message.js): `models/Message.js`
- [MongoDB Connection](https://github.com/chiru-5/lawezy/blob/main/lib/mongodb.js): `lib/mongodb.js`

### Other components

- **Citizen**
- **Advocate**

## Connections

- Citizen → Account Pages: creates account
- Account Pages → Session Provider: submits credentials (evidence: `app/signup/page.jsx`)
- Session Provider → Authentication API: registers account (evidence: `lib/auth-provider.jsx`)
- Session Provider → Login API: authenticates (evidence: `lib/auth-provider.jsx`)
- Profile Editor → Session Provider: updates profile (evidence: `app/profile/page.jsx`)
- Citizen → Advocate Directory: finds advocate (evidence: `README.md`)
- Advocate Directory → Appointment Booking: opens booking (evidence: `app/appointments/page.jsx`)
- Citizen → Appointment Booking: requests consultation (evidence: `README.md`)
- Advocate → Appointment API: manages bookings (evidence: `README.md`)
- Appointment Booking → Appointment API: submits booking
- Appointment API → Appointment Model: uses model (evidence: `app/api/appointments/route.js`)
- Appointment API → MongoDB Connection: connects (evidence: `app/api/appointments/route.js`)
- Citizen → AI Consultation UI: asks legal question (evidence: `README.md`)
- AI Consultation UI → Legal AI Engine: requests response (evidence: `app/ai-chat/page.jsx`)
- Citizen → Legal Blogs: reads articles (evidence: `README.md`)
- Legal Blogs → Blog API: loads articles
- Blog API → Blog Model: uses model (evidence: `app/api/blogs/route.js`)
- Blog API → MongoDB Connection: connects (evidence: `app/api/blogs/route.js`)
- Citizen → Legal Resources: browses templates (evidence: `README.md`)
- Legal Resources → Resource API: loads resources
- Resource API → Resource Model: uses model (evidence: `app/api/resources/route.js`)
- Resource API → MongoDB Connection: connects (evidence: `app/api/resources/route.js`)
- Citizen → Direct Messaging: messages advocate (evidence: `README.md`)
- Direct Messaging → Message Model: stores conversations (evidence: `README.md`)
- Advocate API → User Model: uses model (evidence: `app/api/users/route.js`)
- Advocate API → MongoDB Connection: connects (evidence: `app/api/users/route.js`)
- Authentication API → User Model: uses model (evidence: `app/api/auth/register/route.js`)
- Authentication API → MongoDB Connection: connects (evidence: `app/api/auth/register/route.js`)
- Login API → User Model: uses model (evidence: `app/api/auth/login/route.js`)
- Login API → MongoDB Connection: connects (evidence: `app/api/auth/login/route.js`)
- Advocate → Advocate API: listed in directory (evidence: `README.md`)
