# aravindan-001/cit2026 architecture

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

- Interactive diagram: https://gitdiagram.com/aravindan-001/cit2026
- Repository: https://github.com/aravindan-001/cit2026

## Overview

#### Purpose and Entry Points
This is a brand/social-media analysis system with a Python API backend and static HTML/JavaScript dashboard UI. Backend startup is `app/main.py`; API routes are composed in `app/api/router.py`. Browser entry pages include `index.html`, `analyze.html`, `insights.html`, `alerts.html`, and `history.html`.

#### Application Boundary
The backend is organized as a FastAPI-style service: endpoint modules accept HTTP requests, delegate business operations to services, and return schema-shaped responses. Route families are separated by domain:
- Brands: `app/api/endpoints/brands.py`
- Social posts: `app/api/endpoints/social_posts.py`
- Route registration: `app/api/router.py`

#### Brand and Social Content Domain
Persistent domain entities cover brands, social posts, analyses, generated reports, and users:
- `app/models/brand.py`
- `app/models/social_post.py`
- `app/models/analysis.py`
- `app/models/brand_report.py`
- `app/models/user.py`

Request/response contracts are separated from ORM/domain models in `app/schemas/brand.py`, `app/schemas/social_post.py`, `app/schemas/analysis.py`, and `app/schemas/brand_report.py`.

#### Service and Analysis Pipeline
Services form the principal orchestration layer between HTTP and storage/processing:
- Brand lifecycle and lookup: `app/services/brand_service.py`
- Social-post ingestion/querying: `app/services/social_post_service.py`

Analysis is a distinct processing boundary. `app/nlp/analyzer.py` performs NLP-oriented analysis of content, while `app/intelligence/report_generator.py` turns analysis/domain data into brand reports. The expected flow is: API request → service retrieves or persists brand/posts → NLP analysis → report generation → schema response/persisted report.

#### Persistence and Migration Infrastructure
Database connectivity is centralized in `app/database/connection.py`, with package-level database integration in `app/database/__init__.py`. Schema evolution uses Alembic:
- Runtime migration configuration: `alembic/env.py`
- Initial database schema: `alembic/versions/0b7a88261649_initial_schema.py`
- Migration settings: `alembic.ini`

Environment-driven application settings are defined in `app/config.py`, with expected local variables represented by `.env.example`.

#### Frontend Integration
The frontend is a static multi-page dashboard that calls the backend through a shared API layer:
- HTTP client: `js/api-client.js`
- Client configuration: `js/config.js`
- Analysis interaction: `js/analyze.js`
- Brand search interaction: `js/brand-search.js`
- Dashboard and insights views: `js/dashboard.js`, `js/insights.js`

Page-specific CSS and JavaScript keep presentation outside the Python service. `js/mock-data.js` indicates the UI may support demo/mock rendering when live API data is unavailable.

#### Deployment Runtime
The deployable backend requires Python dependencies listed in `requirements.txt` and is configured for Render through `render.yaml`. The static frontend assets are repository-root HTML, `js/`, `css/`, and `assets/`; they can be served independently or alongside the API depending on deployment configuration.

Main entry points: [`app/models/brand.py`](https://github.com/aravindan-001/cit2026/blob/main/app/models/brand.py) (Domain models), [`app/api/router.py`](https://github.com/aravindan-001/cit2026/blob/main/app/api/router.py) (Route composition), [`app/api/endpoints/brands.py`](https://github.com/aravindan-001/cit2026/blob/main/app/api/endpoints/brands.py) (Brand endpoints), [`app/api/endpoints/social_posts.py`](https://github.com/aravindan-001/cit2026/blob/main/app/api/endpoints/social_posts.py) (Social post endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Static Dashboard"]
  node_pages["Dashboard pages<br/>HTML pages<br/>[index.html]"]
  node_frontend_features["UI interactions<br/>browser modules<br/>[analyze.js]"]
  node_api_client["Shared API client<br/>JavaScript HTTP client<br/>[api-client.js]"]
  node_client_config["Client configuration<br/>JavaScript config<br/>[config.js]"]
  node_mock_data["Mock data fallback<br/>demo data<br/>[mock-data.js]"]
end

subgraph group_api["Python API"]
  node_backend_entry{{"API startup<br/>FastAPI application<br/>[main.py]"}}
  node_api_router["Route composition<br/>router<br/>[router.py]"]
  node_brand_routes["Brand endpoints<br/>HTTP endpoints<br/>[brands.py]"]
  node_post_routes["Social post endpoints<br/>HTTP endpoints<br/>[social_posts.py]"]
  node_contracts["API schemas<br/>request/response contracts<br/>[analysis.py]"]
  node_brand_service["Brand service<br/>business service<br/>[brand_service.py]"]
  node_post_service["Social post service<br/>business service"]
end

subgraph group_processing["Analysis Pipeline"]
  node_nlp_analyzer["NLP analyzer<br/>content analysis<br/>[analyzer.py]"]
  node_report_generator["Report generator<br/>intelligence service"]
end

subgraph group_data["Data &amp; Schema"]
  node_domain_models["Domain models<br/>ORM entities<br/>[brand.py]"]
  node_database[("Database connection<br/>persistence integration<br/>[connection.py]")]
  node_migrations["Alembic migrations<br/>schema evolution<br/>[env.py]"]
end

node_deployment["Deployment runtime<br/>Render deployment<br/>[render.yaml]"]

node_pages -->|"loads"| node_frontend_features
node_frontend_features -->|"uses"| node_api_client
node_client_config -->|"configures"| node_api_client
node_mock_data -.->|"fallback data"| node_frontend_features
node_api_client -->|"HTTP requests"| node_backend_entry
node_backend_entry -->|"mounts"| node_api_router
node_api_router -->|"registers"| node_brand_routes
node_api_router -->|"registers"| node_post_routes
node_brand_routes -->|"delegates"| node_brand_service
node_post_routes -->|"delegates"| node_post_service
node_brand_routes -->|"returns"| node_contracts
node_post_routes -->|"returns"| node_contracts
node_brand_service -->|"reads and persists"| node_domain_models
node_post_service -->|"reads and persists"| node_domain_models
node_domain_models -->|"stored through"| node_database
node_post_service -->|"submits content"| node_nlp_analyzer
node_nlp_analyzer -->|"analysis results"| node_report_generator
node_brand_service -->|"brand context"| node_report_generator
node_report_generator -->|"persists reports"| node_domain_models
node_migrations -->|"evolves schema"| node_database
node_deployment -.->|"deploys"| node_backend_entry

click node_pages "https://github.com/aravindan-001/cit2026/blob/main/index.html"
click node_frontend_features "https://github.com/aravindan-001/cit2026/blob/main/js/analyze.js"
click node_api_client "https://github.com/aravindan-001/cit2026/blob/main/js/api-client.js"
click node_client_config "https://github.com/aravindan-001/cit2026/blob/main/js/config.js"
click node_mock_data "https://github.com/aravindan-001/cit2026/blob/main/js/mock-data.js"
click node_backend_entry "https://github.com/aravindan-001/cit2026/blob/main/app/main.py"
click node_api_router "https://github.com/aravindan-001/cit2026/blob/main/app/api/router.py"
click node_brand_routes "https://github.com/aravindan-001/cit2026/blob/main/app/api/endpoints/brands.py"
click node_post_routes "https://github.com/aravindan-001/cit2026/blob/main/app/api/endpoints/social_posts.py"
click node_contracts "https://github.com/aravindan-001/cit2026/blob/main/app/schemas/analysis.py"
click node_brand_service "https://github.com/aravindan-001/cit2026/blob/main/app/services/brand_service.py"
click node_post_service "https://github.com/aravindan-001/cit2026/blob/main/app/services/social_post_service.py"
click node_nlp_analyzer "https://github.com/aravindan-001/cit2026/blob/main/app/nlp/analyzer.py"
click node_report_generator "https://github.com/aravindan-001/cit2026/blob/main/app/intelligence/report_generator.py"
click node_domain_models "https://github.com/aravindan-001/cit2026/blob/main/app/models/brand.py"
click node_database "https://github.com/aravindan-001/cit2026/blob/main/app/database/connection.py"
click node_migrations "https://github.com/aravindan-001/cit2026/blob/main/alembic/env.py"
click node_deployment "https://github.com/aravindan-001/cit2026/blob/main/render.yaml"

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_pages,node_frontend_features,node_api_client,node_client_config,node_mock_data toneBlue
class node_backend_entry,node_api_router,node_brand_routes,node_post_routes,node_contracts,node_brand_service,node_post_service toneAmber
class node_nlp_analyzer,node_report_generator toneMint
class node_domain_models,node_database,node_migrations toneRose
class node_deployment toneNeutral
```

## Components

### Static Dashboard

Multi-page browser UI and shared client code.

- [Dashboard pages](https://github.com/aravindan-001/cit2026/blob/main/index.html): HTML pages · Entry pages include analysis, insights, alerts, and history views. · `index.html`
- [UI interactions](https://github.com/aravindan-001/cit2026/blob/main/js/analyze.js): browser modules · Analysis, brand search, dashboard, and insights behavior. · `js/analyze.js`
- [Shared API client](https://github.com/aravindan-001/cit2026/blob/main/js/api-client.js): JavaScript HTTP client · `js/api-client.js`
- [Client configuration](https://github.com/aravindan-001/cit2026/blob/main/js/config.js): JavaScript config · `js/config.js`
- [Mock data fallback](https://github.com/aravindan-001/cit2026/blob/main/js/mock-data.js): demo data · Supports rendering when live API data is unavailable. · `js/mock-data.js`

### Python API

FastAPI-style HTTP boundary and orchestration.

- [API startup](https://github.com/aravindan-001/cit2026/blob/main/app/main.py): FastAPI application · `app/main.py`
- [Route composition](https://github.com/aravindan-001/cit2026/blob/main/app/api/router.py): router · `app/api/router.py`
- [Brand endpoints](https://github.com/aravindan-001/cit2026/blob/main/app/api/endpoints/brands.py): HTTP endpoints · `app/api/endpoints/brands.py`
- [Social post endpoints](https://github.com/aravindan-001/cit2026/blob/main/app/api/endpoints/social_posts.py): HTTP endpoints · `app/api/endpoints/social_posts.py`
- [API schemas](https://github.com/aravindan-001/cit2026/blob/main/app/schemas/analysis.py): request/response contracts · Separate schema layer for brands, posts, analyses, and reports. · `app/schemas/analysis.py`
- [Brand service](https://github.com/aravindan-001/cit2026/blob/main/app/services/brand_service.py): business service · Brand lifecycle and lookup orchestration. · `app/services/brand_service.py`
- [Social post service](https://github.com/aravindan-001/cit2026/blob/main/app/services/social_post_service.py): business service · Social-post ingestion and querying. · `app/services/social_post_service.py`

### Analysis Pipeline

Content analysis and report production.

- [NLP analyzer](https://github.com/aravindan-001/cit2026/blob/main/app/nlp/analyzer.py): content analysis · `app/nlp/analyzer.py`
- [Report generator](https://github.com/aravindan-001/cit2026/blob/main/app/intelligence/report_generator.py): intelligence service · Builds brand reports from analysis and domain data. · `app/intelligence/report_generator.py`

### Data & Schema

Persistent entities, database access, and migrations.

- [Domain models](https://github.com/aravindan-001/cit2026/blob/main/app/models/brand.py): ORM entities · Brands, posts, analyses, reports, and users. · `app/models/brand.py`
- [Database connection](https://github.com/aravindan-001/cit2026/blob/main/app/database/connection.py): persistence integration · Central runtime database connectivity. · `app/database/connection.py`
- [Alembic migrations](https://github.com/aravindan-001/cit2026/blob/main/alembic/env.py): schema evolution · Initial schema and runtime migration configuration. · `alembic/env.py`

### Other components

- [Deployment runtime](https://github.com/aravindan-001/cit2026/blob/main/render.yaml): Render deployment · Backend dependencies and deployment configuration. · `render.yaml`

## Connections

- Dashboard pages → UI interactions: loads
- UI interactions → Shared API client: uses
- Client configuration → Shared API client: configures
- Mock data fallback → UI interactions: fallback data
- Shared API client → API startup: HTTP requests
- API startup → Route composition: mounts
- Route composition → Brand endpoints: registers
- Route composition → Social post endpoints: registers
- Brand endpoints → Brand service: delegates
- Social post endpoints → Social post service: delegates
- Brand endpoints → API schemas: returns
- Social post endpoints → API schemas: returns
- Brand service → Domain models: reads and persists
- Social post service → Domain models: reads and persists
- Domain models → Database connection: stored through
- Social post service → NLP analyzer: submits content
- NLP analyzer → Report generator: analysis results
- Brand service → Report generator: brand context
- Report generator → Domain models: persists reports
- Alembic migrations → Database connection: evolves schema
- Deployment runtime → API startup: deploys
