Skip to content

Repository files navigation

App Store Analytics

Note: This project was generated by AI (GitHub Copilot) based on a detailed specification prompt.

A .NET 10 MVC web service that ingests analytics from Google Play, Apple App Store, and Huawei AppGallery, stores normalized data in PostgreSQL, and provides a dashboard with Chart.js visualizations.

Architecture

┌──────────────────────────────────────────────────────────────┐
│                         Web Layer                            │
│  Controllers │ Views (Razor + Chart.js) │ API Key Middleware │
├──────────────────────────────────────────────────────────────┤
│                      Application Layer                       │
│  DTOs │ Service Interfaces │ DashboardService │ Orchestrator │
├──────────────────────────────────────────────────────────────┤
│                    Infrastructure Layer                       │
│  EF Core │ Repositories │ API Clients │ Quartz Jobs          │
├──────────────────────────────────────────────────────────────┤
│                       Domain Layer                           │
│  Entities │ Enums │ Repository Interfaces │ Unit of Work      │
└──────────────────────────────────────────────────────────────┘
                            │
                     ┌──────┴──────┐
                     │ PostgreSQL  │
                     └─────────────┘

Quick Start with Docker Compose

docker compose up --build

The web app will be available at http://localhost:8080. PostgreSQL runs on port 5432. Migrations apply automatically on startup.

Deploy to IIS (with External PostgreSQL)

Prerequisites

  • Windows Server with IIS enabled
  • .NET 10 Hosting Bundle installed on the server
  • PostgreSQL 16 accessible from the server

1. Publish the application

dotnet publish src/Web/AppStoreAnalytics.Web.csproj -c Release -o ./publish

2. Apply the database migration

Run this once from your development machine (or the server) pointing at your external database:

dotnet ef database update \
  --project src/Infrastructure/AppStoreAnalytics.Infrastructure.csproj \
  --startup-project src/Web/AppStoreAnalytics.Web.csproj \
  --connection "Host=YOUR_DB_SERVER;Port=5432;Database=appstoreanalytics;Username=YOUR_USER;Password=YOUR_PASSWORD"

3. Configure the connection string

Edit publish/appsettings.Production.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Host=YOUR_DB_SERVER;Port=5432;Database=appstoreanalytics;Username=YOUR_USER;Password=YOUR_PASSWORD;SSL Mode=Prefer;Trust Server Certificate=true"
  }
}

Or set it as an environment variable in IIS: ConnectionStrings__DefaultConnection

4. Set up the IIS site

  1. Copy the publish folder to your server (e.g. C:\inetpub\appstoreanalytics)
  2. Open IIS ManagerAdd Website
    • Site name: AppStoreAnalytics
    • Physical path: C:\inetpub\appstoreanalytics
    • Binding: choose your port/hostname
  3. Set the Application Pool:
    • Select the pool → Basic Settings.NET CLR version: No Managed Code
  4. Create the logs folder inside the publish directory for stdout logging
  5. Browse to the site — the dashboard will load at /

5. Verify

  • Dashboard: https://your-server/
  • API test: curl -H "X-Api-Key: YOUR_KEY" https://your-server/api/ingestion/run-all

Local Development

Prerequisites

  • .NET 10 SDK
  • PostgreSQL 16 (local install or any accessible server)

Configure the database

Edit src/Web/appsettings.Development.json with your PostgreSQL connection:

{
  "ConnectionStrings": {
    "DefaultConnection": "Host=YOUR_SERVER;Port=5432;Database=appstoreanalytics;Username=YOUR_USER;Password=YOUR_PASSWORD"
  }
}

Migrations apply automatically in Development mode.

Run the web app

cd src/Web
dotnet run

Run tests

dotnet test

Configure API Keys

Edit src/Web/appsettings.json or set environment variables:

Google Play

  1. Create a service account in Google Cloud Console
  2. Grant access in Google Play Console → API Access
  3. Set AppStoreCredentials__GooglePlay__ServiceAccountJsonPath to the JSON key file path

Apple App Store Connect

  1. Generate an API key in App Store Connect → Users → Keys
  2. Set IssuerId, KeyId, and PrivateKeyPath in configuration

Huawei AppGallery Connect

  1. Go to AppGallery Connect → API Client
  2. Create credentials and set ClientId and ClientSecret

Ingestion API Key

Set IngestionApiKey__ApiKey to a secure random string. All /api/* endpoints require the X-Api-Key header.

Trigger Ingestion Manually

# Ingest all stores for all apps
curl -X POST http://localhost:8080/api/ingestion/run-all \
  -H "X-Api-Key: change-me-to-a-secure-random-key"

# Ingest specific store for specific app
curl -X POST http://localhost:8080/api/ingestion/run/GooglePlay/1 \
  -H "X-Api-Key: change-me-to-a-secure-random-key"

Store types: GooglePlay (1), Apple (2), Huawei (3).

Daily Ingestion Schedule

Quartz.NET runs DailyIngestionJob at 2:00 AM UTC daily. To change the schedule, modify the cron expression in src/Infrastructure/DependencyInjection.cs:

q.AddTrigger(opts => opts
    .ForJob(jobKey)
    .WithIdentity("DailyIngestionTrigger")
    .WithCronSchedule("0 0 2 * * ?"));  // cron expression

Extend for Additional Stores

  1. Add entity (if needed) in src/Domain/Enums/StoreType.cs
  2. Create API client implementing IStoreApiClient in src/Infrastructure/ApiClients/
  3. Create ingestion service extending BaseIngestionService in src/Infrastructure/Services/
  4. Register in src/Infrastructure/DependencyInjection.cs:
    services.AddHttpClient<NewStoreApiClient>();
    services.AddScoped<IStoreApiClient, NewStoreApiClient>();
    services.AddScoped<IIngestionService, NewStoreIngestionService>();
  5. Seed store record in AppDbContext.OnModelCreating

Database Tables

Table Description
apps Registered applications
stores Store definitions (seeded)
daily_installs Daily install counts per store/country
ratings Rating snapshots per store
reviews Individual reviews
countries Country reference data
store_credentials Encrypted API credentials
ingestion_logs Ingestion run history

Project Structure

/src
  /Domain          → Entities, enums, repository interfaces
  /Application     → DTOs, service interfaces, business logic
  /Infrastructure  → EF Core, API clients, Quartz jobs
  /Web             → MVC controllers, Razor views, middleware
/tests
  /UnitTests       → xUnit + Moq tests for services
  /IntegrationTests → API endpoint tests (requires DB)

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages