How aravindan-001/cit2026 works
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: brand.py Domain models · router.py Route composition · brands.py Brand endpoints · social_posts.py Social post endpoints
Components 18
Static Dashboard
Multi-page browser UI and shared client code.
- Dashboard pages · Entry pages include analysis, insights, alerts, and history views.
index.html - UI interactions · Analysis, brand search, dashboard, and insights behavior.
js/analyze.js - Shared API client
js/api-client.js - Client configuration
js/config.js - Mock data fallback · Supports rendering when live API data is unavailable.
js/mock-data.js
Python API
FastAPI-style HTTP boundary and orchestration.
- API startup
app/main.py - Route composition
app/api/router.py - Brand endpoints
app/api/endpoints/brands.py - Social post endpoints
app/api/endpoints/social_posts.py - API schemas · Separate schema layer for brands, posts, analyses, and reports.
app/schemas/analysis.py - Brand service · Brand lifecycle and lookup orchestration.
app/services/brand_service.py - Social post service · Social-post ingestion and querying.
app/services/social_post_service.py
Analysis Pipeline
Content analysis and report production.
- NLP analyzer
app/nlp/analyzer.py - Report generator · Builds brand reports from analysis and domain data.
app/intelligence/report_generator.py
Data & Schema
Persistent entities, database access, and migrations.
- Domain models · Brands, posts, analyses, reports, and users.
app/models/brand.py - Database connection · Central runtime database connectivity.
app/database/connection.py - Alembic migrations · Initial schema and runtime migration configuration.
alembic/env.py
Other components
- Deployment runtime · Backend dependencies and deployment configuration.
render.yaml
Connections 21
- 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