### Initialize and Start Backend and Frontend Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md Use this command to initialize the project by cloning submodules and installing dependencies, then start both the backend and frontend servers. ```bash # Initialize (clone submodules + install deps) make init # Set up environment test -f .env || cp sample.env .env # then set DEEPGRAM_API_KEY # Start both servers make start # Backend: http://localhost:8081 # Frontend: http://localhost:8080 ``` -------------------------------- ### Install Frontend Dependencies Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md Navigate to the frontend directory and install its dependencies using corepack and pnpm. ```bash cd frontend && corepack pnpm install ``` -------------------------------- ### Install Backend Dependencies with vcpkg and CMake Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md This command installs backend C++ dependencies using vcpkg and configures the build using CMake. Ensure the VCPKG_ROOT environment variable is set. ```bash cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" && cmake --build build ``` -------------------------------- ### Start Backend and Frontend Separately Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md These commands allow you to start the backend and frontend servers independently in separate terminals. Ensure you have set up the environment variables, including DEEPGRAM_API_KEY. ```bash # Terminal 1 — Backend ./build/app ``` ```bash # Terminal 2 — Frontend cd frontend && corepack pnpm run dev -- --port 8080 --no-open ``` -------------------------------- ### Initialize and Start C++ App Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/README.md Use this Makefile command to set up the project locally. Ensure your DEEPGRAM_API_KEY is added to the .env file. ```bash make init cp sample.env .env # Add your DEEPGRAM_API_KEY make start ``` -------------------------------- ### Conventional Commits Examples Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md Follow conventional commits format for all commits. This ensures a consistent and understandable commit history. ```bash feat(cpp-text-intelligence): add diarization support ``` ```bash fix(cpp-text-intelligence): resolve WebSocket close handling ``` ```bash refactor(cpp-text-intelligence): simplify session endpoint ``` ```bash chore(deps): update frontend submodule ``` -------------------------------- ### Analyze content from a URL Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Analyze content fetched from a provided URL. This example enables summarization (v2) and topic detection. The request must include either 'text' or 'url'. ```bash # Analyze content from a URL curl -X POST "http://localhost:8081/api/text-intelligence?summarize=v2&topics=true" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/article.html" }' ``` -------------------------------- ### GET /api/metadata Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Returns metadata from the deepgram.toml configuration file. ```APIDOC ## GET /api/metadata ### Description Returns metadata from the deepgram.toml configuration file, providing information about the application including title, description, author, use case, and supported features. ### Method GET ### Endpoint /api/metadata ### Response #### Success Response (200) - **title** (string) - Application title. - **description** (string) - Application description. - **author** (string) - Author information. - **repository** (string) - Source code repository URL. - **useCase** (string) - Primary use case. - **language** (string) - Programming language. - **framework** (string) - Web framework used. - **tags** (array) - List of relevant tags. ``` -------------------------------- ### GET /health Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Returns service health status for monitoring and load balancer health checks. ```APIDOC ## GET /health ### Description Returns service health status for monitoring and load balancer health checks. ### Method GET ### Endpoint /health ### Response #### Success Response (200) - **status** (string) - Service status (e.g., "ok"). - **service** (string) - Service name. ``` -------------------------------- ### GET /api/session Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Issues a signed JWT session token required for authenticated API requests. Tokens expire after 1 hour. ```APIDOC ## GET /api/session ### Description Issues a signed JWT session token required for authenticated API requests. Tokens expire after 1 hour and must be included in the Authorization header for subsequent API calls. ### Method GET ### Endpoint /api/session ### Response #### Success Response (200) - **token** (string) - The signed JWT session token. #### Response Example { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` -------------------------------- ### Create .env from sample Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Copy the sample environment file to .env to configure the application. This file should contain required credentials and optional server settings. ```bash # Create .env from sample cp sample.env .env ``` -------------------------------- ### Project Build and Execution Commands Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Use these Make commands to manage project initialization, server execution, testing, and cleanup. ```bash # Check prerequisites (git, cmake, pnpm) make check-prereqs # Initialize project: clone submodules, build C++, install frontend deps make init # Start both backend (port 8081) and frontend (port 8080) servers make start # Start backend only make start-backend # Start frontend development server only make start-frontend # Build frontend for production make build # Update submodules to latest commits make update # Run contract conformance tests make test # Clean all build artifacts make clean # Show git and submodule status make status # Eject frontend from submodule to regular directory (irreversible) make eject-frontend ``` -------------------------------- ### CMake Build Configuration Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Build the C++ backend using CMake and vcpkg for dependency management. ```bash # Configure with vcpkg toolchain cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake # Build the project cmake --build build # Run the server directly ./build/cpp-text-intelligence ``` -------------------------------- ### Run Conformance Tests Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md Execute conformance tests to ensure the application is running correctly. This command requires the application to be running. ```bash make test ``` -------------------------------- ### Environment Configuration Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Set the session secret for authentication. If omitted, a random secret is generated at startup, causing session invalidation on restart. ```text # If not set, a random secret is generated at startup (sessions invalidate on restart) SESSION_SECRET=your_secure_random_string_here ``` -------------------------------- ### Fetch application metadata Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Retrieve metadata about the C++ Text Intelligence Starter application, including its title, description, author, and supported features, from the deepgram.toml configuration. ```bash # Fetch application metadata curl -X GET http://localhost:8081/api/metadata ``` ```json { "title": "C++ Text Intelligence Starter", "description": "Get started using Deepgram's Text Intelligence with this C++ demo app", "author": "Deepgram DX Team (https://developers.deepgram.com)", "repository": "https://github.com/deepgram-starters/cpp-text-intelligence", "useCase": "text-intelligence", "language": "C++", "framework": "Crow", "sdk": "N/A", "tags": ["text-intelligence", "text-analysis", "nlp", "natural-language-processing", "cpp", "crow"] } ``` -------------------------------- ### Clean Rebuild Project Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md Use this command to perform a clean rebuild of the project. It removes build artifacts and node modules before re-initializing dependencies. ```bash rm -rf build frontend/node_modules frontend/.vite make init ``` -------------------------------- ### Update Frontend Submodule Reference Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md After pushing frontend changes, update the main project's reference to the frontend submodule. ```bash cd .. && git add frontend && git commit -m "chore(deps): update frontend submodule" ``` -------------------------------- ### Commit Frontend Changes in Submodule Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md After making changes to the frontend files, use these commands to stage, commit, and push the changes within the frontend git submodule. ```bash cd frontend && git add . && git commit -m "feat: description" ``` ```bash cd frontend && git push origin main ``` -------------------------------- ### Analyze text with all intelligence features Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Process text content for comprehensive analysis including summarization, topic detection, sentiment analysis, and intent recognition. Ensure a valid session token is provided. ```bash # Analyze text with all intelligence features enabled curl -X POST "http://localhost:8081/api/text-intelligence?summarize=true&topics=true&sentiment=true&intents=true" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "text": "Artificial intelligence is transforming how businesses operate. Companies are investing heavily in AI solutions to improve efficiency and customer experience. The technology enables automation of repetitive tasks and provides valuable insights from data analysis." }' ``` ```json { "results": { "summary": { "text": "AI is transforming business operations through automation and data insights." }, "topics": [ {"topic": "artificial intelligence", "confidence": 0.95}, {"topic": "business automation", "confidence": 0.87} ], "sentiments": [ {"sentiment": "positive", "confidence": 0.82} ], "intents": [ {"intent": "inform", "confidence": 0.91} ] } } ``` -------------------------------- ### Stop Backend and Frontend Servers Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md This command forcefully terminates any processes listening on ports 8080 and 8081, effectively stopping both the frontend and backend servers. ```bash lsof -ti:8080,8081 | xargs kill -9 2>/dev/null ``` -------------------------------- ### Use session token in subsequent requests Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Include the obtained session token in the Authorization header for subsequent API calls to authenticate your requests. ```bash # Use the token in subsequent requests curl -X POST http://localhost:8081/api/text-intelligence \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \ -H "Content-Type: application/json" \ -d '{"text": "Your text here"}' ``` -------------------------------- ### Manual Endpoint Checks Source: https://github.com/deepgram-starters/cpp-text-intelligence/blob/main/AGENTS.md Perform manual checks on the API endpoints to verify their functionality. These commands use curl to send requests and python3 to format the JSON output. ```bash curl -sf http://localhost:8081/api/metadata | python3 -m json.tool ``` ```bash curl -sf http://localhost:8081/api/session | python3 -m json.tool ``` -------------------------------- ### Request a new session token Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Use this endpoint to obtain a signed JWT session token. Tokens are required for authenticated API requests and expire after 1 hour. ```bash # Request a new session token curl -X GET http://localhost:8081/api/session ``` ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MDk4MjM0NTYsImV4cCI6MTcwOTgyNzA1Nn0.abc123..." } ``` -------------------------------- ### Error response for invalid requests Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Handles errors when a request is invalid, such as missing the required 'text' or 'url' field. The response includes error type, code, and a descriptive message. ```json { "error": { "type": "validation_error", "code": "INVALID_TEXT", "message": "Request must contain either 'text' or 'url' field", "details": {} } } ``` -------------------------------- ### Check service health Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Perform a health check on the service to ensure it is operational. This endpoint is useful for monitoring and load balancer health checks. ```bash # Check service health curl -X GET http://localhost:8081/health ``` ```json { "status": "ok", "service": "text-intelligence" } ``` -------------------------------- ### POST /api/text-intelligence Source: https://context7.com/deepgram-starters/cpp-text-intelligence/llms.txt Processes text content or URLs through Deepgram's Read API for intelligent analysis including summarization, topics, sentiment, and intents. ```APIDOC ## POST /api/text-intelligence ### Description Processes text content through Deepgram's Read API for intelligent analysis. Accepts either raw text or a URL to fetch content from. ### Method POST ### Endpoint /api/text-intelligence ### Parameters #### Query Parameters - **summarize** (boolean/string) - Optional - Enable summarization (v2). - **topics** (boolean) - Optional - Enable topic detection. - **sentiment** (boolean) - Optional - Enable sentiment analysis. - **intents** (boolean) - Optional - Enable intent recognition. #### Request Body - **text** (string) - Optional - Raw text to analyze. - **url** (string) - Optional - URL to fetch content from. ### Request Example { "text": "Artificial intelligence is transforming how businesses operate." } ### Response #### Success Response (200) - **results** (object) - Contains analysis results for summary, topics, sentiments, and intents. #### Response Example { "results": { "summary": { "text": "AI is transforming business operations." }, "topics": [{"topic": "artificial intelligence", "confidence": 0.95}], "sentiments": [{"sentiment": "positive", "confidence": 0.82}], "intents": [{"intent": "inform", "confidence": 0.91}] } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.