How swathi-88/competesmart works
Purpose and Entry Points
CompeteSmart is a market-intelligence and strategy-simulation system: it collects competitive-market data, derives semantic and temporal signals, projects experiment outcomes, and exposes an AI copilot. The primary backend entry point is the FastAPI app in backend/api.py; backend/main.py and backend/prototype_pipeline.py appear to support pipeline execution/prototyping. The Next.js App Router frontend starts from frontend/src/app/page.tsx, with operational views at frontend/src/app/dashboard/page.tsx and frontend/src/app/experiment-builder/page.tsx.
Client Application
The frontend provides the user-facing dashboard, experiment workspace, authenticated access, and copilot interaction. frontend/src/utils/api.ts is the API boundary to the FastAPI service, configured through NEXT_PUBLIC_API_URL. Simulation UI composition is centered on frontend/src/components/simulation/SimulationOrchestrator.tsx, with KPI and history views in frontend/src/components/simulation/LiveKpiPanel.tsx and frontend/src/components/simulation/ExperimentHistory.tsx.
API and Application Boundary
FastAPI routes in backend/api.py coordinate requests from the frontend into authentication, intelligence retrieval, simulations, and copilot behavior. Authentication is separated in backend/src/auth.py; persistence and database session/access concerns are centralized in backend/src/database.py. Domain models are defined in backend/src/models.py, forming the contract between API, persistence, and analytical stages.
Market Data Acquisition and Persistence
The scraper subsystem is an independently structured ingestion boundary under backend/web-scraper/. backend/web-scraper/scraper.py obtains external market content, backend/web-scraper/parser.py converts it into usable records, and backend/web-scraper/db.py persists ingestion results. backend/web-scraper/scheduler.py suggests recurring collection rather than frontend-triggered scraping. PostgreSQL with pgvector is the stated system of record for structured market data and vector similarity data.
Intelligence Pipeline
The intelligence layer transforms ingested market content into searchable, decision-ready representations. backend/src/embedding_pipeline.py and backend/src/intelligence/embeddings.py generate embeddings; backend/src/semantic_search.py retrieves semantically relevant market context from pgvector-backed storage. Signal extraction, clustering, and time-oriented analysis are separated into backend/src/intelligence/signal_extraction.py, backend/src/intelligence/clustering.py, and backend/src/intelligence/temporal.py. Their output is likely normalized through schemas in backend/src/intelligence/schemas.py.
Decision, Trust, and Simulation
Strategic reasoning is layered above intelligence results. backend/decision_layer.py represents the decision/simulation layer that turns market signals and hypothetical pivots into projected outcomes. backend/src/trust_layer.py is an explicit validation/governance boundary around AI-generated or inferred recommendations. backend/src/intelligence/advanced.py likely provides higher-order analysis feeding these stages. Persisted or inspectable decision output is represented by backend/decision_layer_output.json.
AI Copilot and External Services
backend/src/execution_copilot.py supplies context-aware strategic guidance, using retrieved market intelligence and decision outputs rather than operating as a standalone chat service. The backend requires OpenAI and Google Gemini credentials, so model-provider calls are an external-service boundary; PostgreSQL/pgvector is the data-service boundary. The runtime is Python 3.10+ with FastAPI (backend/requirements.txt, backend/runtime.txt); the client is Next.js 15+ (frontend/package.json) and communicates over HTTP.
Main entry points: api.py FastAPI routes · semantic_search.py Semantic retrieval · execution_copilot.py Execution copilot · decision_layer.py Strategy simulation
Components 18
Next.js Client
- Dashboard & experiment views
frontend/src/app/dashboard/page.tsx - Simulation workspace
frontend/src/components/simulation/SimulationOrchestrator.tsx - API client
frontend/src/utils/api.ts
FastAPI Application
- FastAPI routes · Coordinates authentication, intelligence, simulations, and copilot requests.
backend/api.py - Authentication
backend/src/auth.py - Domain models
backend/src/models.py
Market Ingestion
- Collection scheduler
backend/web-scraper/scheduler.py - Market scraper
backend/web-scraper/scraper.py - Content parser
backend/web-scraper/parser.py - Ingestion persistence
backend/web-scraper/db.py
Intelligence & Decisions
- Embedding generation
backend/src/embedding_pipeline.py - Semantic retrieval
backend/src/semantic_search.py - Signals, clusters & temporal analysis
backend/src/intelligence/signal_extraction.py - Strategy simulation · Projects outcomes from market signals and hypothetical pivots.
backend/decision_layer.py - Recommendation governance
backend/src/trust_layer.py - Execution copilot · Produces context-aware strategic guidance.
backend/src/execution_copilot.py
Other components
- PostgreSQL + pgvector · Stores structured market data and vector similarity data.
- OpenAI & Gemini
Connections 21
- Dashboard & experiment views → Simulation workspace: renders
- Simulation workspace → API client: uses
- API client → FastAPI routes: HTTP
- FastAPI routes → Authentication: authenticates
- FastAPI routes → Domain models: uses contracts
- FastAPI routes → Semantic retrieval: retrieves context
- FastAPI routes → Strategy simulation: runs simulations
- FastAPI routes → Execution copilot: requests guidance
- Collection scheduler → Market scraper: triggers
- Market scraper → Content parser: market content
- Content parser → Ingestion persistence: records
- Ingestion persistence → PostgreSQL + pgvector: persists
- PostgreSQL + pgvector → Embedding generation: market content
- Embedding generation → PostgreSQL + pgvector: vector records
- Semantic retrieval → PostgreSQL + pgvector: pgvector query
- Semantic retrieval → Signals, clusters & temporal analysis: relevant context
- Signals, clusters & temporal analysis → Strategy simulation: market signals
- Strategy simulation → Recommendation governance: recommendations
- Recommendation governance → Execution copilot: validated outputs
- Semantic retrieval → Execution copilot: retrieved intelligence
- Execution copilot → OpenAI & Gemini: model calls