# prachi1210/gmail-contacts-import architecture

> Architecture diagram of the GitHub repository prachi1210/gmail-contacts-import, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prachi1210/gmail-contacts-import
- Repository: https://github.com/prachi1210/gmail-contacts-import

## Overview

This PHP web app lets users sign in with Google, records their profile, and provides an account and contact-import experience. The visible login flow is handled by index.php: it exchanges an authorization code for a token, retrieves the Google profile, calls the user-check helper, and redirects to the account page. The README documents contact import through Contacts 3.0, but importcontacts.php and the database connection files it names are not present in the supplied tree, so that branch is shown as documented but its wiring is unverified. The sampled client-library code supports OAuth and API requests; other library internals are not traced here.

Main entry points: [`index.php`](https://github.com/prachi1210/gmail-contacts-import/blob/master/index.php) (Login flow), [`src/io/Google_IO.php`](https://github.com/prachi1210/gmail-contacts-import/blob/master/src/io/Google_IO.php) (HTTP transport), [`inc/functions.inc.php`](https://github.com/prachi1210/gmail-contacts-import/blob/master/inc/functions.inc.php) (User lookup), [`src/Google_Client.php`](https://github.com/prachi1210/gmail-contacts-import/blob/master/src/Google_Client.php) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_index["Login flow<br/>[index.php]"]
  node_config["App setup<br/>[config.php]"]
  node_functions["User lookup<br/>[functions.inc.php]"]
  node_account["Account page<br/>[account.php]"]
  node_import["Contact import"]
end

subgraph group_client["Google client library"]
  node_client["API client<br/>[Google_Client.php]"]
  node_oauth["OAuth handling<br/>[Google_OAuth2.php]"]
  node_resource["Service requests"]
  node_http["HTTP transport<br/>[Google_IO.php]"]
end

subgraph group_services["API services"]
  node_oauthservice["Profile API"]
end

node_user(("User"))
node_db[("User database")]
node_google(("Google"))
node_contactsapi(("Contacts API"))

node_user -->|"opens login"| node_index
node_index -->|"loads setup"| node_config
node_index -->|"authenticates"| node_client
node_client -->|"delegates OAuth"| node_oauth
node_oauth -->|"sends token requests"| node_http
node_http -->|"exchanges tokens"| node_google
node_index -->|"requests profile"| node_oauthservice
node_oauthservice -->|"dispatches API call"| node_resource
node_resource -->|"sends request"| node_http
node_http -->|"fetches profile"| node_google
node_index -->|"checks user"| node_functions
node_functions -.->|"reads or writes"| node_db
node_index -->|"redirects"| node_account
node_user -.->|"requests import"| node_import
node_import -.->|"imports contacts"| node_contactsapi
node_contactsapi -.->|"contacts service"| node_google

click node_index "https://github.com/prachi1210/gmail-contacts-import/blob/master/index.php"
click node_config "https://github.com/prachi1210/gmail-contacts-import/blob/master/config.php"
click node_functions "https://github.com/prachi1210/gmail-contacts-import/blob/master/inc/functions.inc.php"
click node_account "https://github.com/prachi1210/gmail-contacts-import/blob/master/account.php"
click node_client "https://github.com/prachi1210/gmail-contacts-import/blob/master/src/Google_Client.php"
click node_oauth "https://github.com/prachi1210/gmail-contacts-import/blob/master/src/auth/Google_OAuth2.php"
click node_resource "https://github.com/prachi1210/gmail-contacts-import/blob/master/src/service/Google_ServiceResource.php"
click node_http "https://github.com/prachi1210/gmail-contacts-import/blob/master/src/io/Google_IO.php"
click node_oauthservice "https://github.com/prachi1210/gmail-contacts-import/blob/master/src/contrib/Google_Oauth2Service.php"

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_index,node_config,node_functions,node_account,node_import,node_user toneBlue
class node_client,node_oauth,node_resource,node_http,node_db toneAmber
class node_oauthservice,node_contactsapi toneMint
class node_google toneIndigo
```

## Components

### Web application

- [Login flow](https://github.com/prachi1210/gmail-contacts-import/blob/master/index.php): `index.php`
- [App setup](https://github.com/prachi1210/gmail-contacts-import/blob/master/config.php): `config.php`
- [User lookup](https://github.com/prachi1210/gmail-contacts-import/blob/master/inc/functions.inc.php): `inc/functions.inc.php`
- [Account page](https://github.com/prachi1210/gmail-contacts-import/blob/master/account.php): `account.php`
- **Contact import**

### Google client library

- [API client](https://github.com/prachi1210/gmail-contacts-import/blob/master/src/Google_Client.php): `src/Google_Client.php`
- [OAuth handling](https://github.com/prachi1210/gmail-contacts-import/blob/master/src/auth/Google_OAuth2.php): `src/auth/Google_OAuth2.php`
- [Service requests](https://github.com/prachi1210/gmail-contacts-import/blob/master/src/service/Google_ServiceResource.php): `src/service/Google_ServiceResource.php`
- [HTTP transport](https://github.com/prachi1210/gmail-contacts-import/blob/master/src/io/Google_IO.php): `src/io/Google_IO.php`

### API services

- [Profile API](https://github.com/prachi1210/gmail-contacts-import/blob/master/src/contrib/Google_Oauth2Service.php): `src/contrib/Google_Oauth2Service.php`

### Other components

- **User**
- **User database**
- **Google**
- **Contacts API**

## Connections

- User → Login flow: opens login
- Login flow → App setup: loads setup
- Login flow → API client: authenticates
- API client → OAuth handling: delegates OAuth
- OAuth handling → HTTP transport: sends token requests
- HTTP transport → Google: exchanges tokens
- Login flow → Profile API: requests profile
- Profile API → Service requests: dispatches API call
- Service requests → HTTP transport: sends request
- HTTP transport → Google: fetches profile
- Login flow → User lookup: checks user
- User lookup → User database: reads or writes
- Login flow → Account page: redirects
- User → Contact import: requests import
- Contact import → Contacts API: imports contacts
- Contacts API → Google: contacts service
