Skip to main content

Prerequisites

Ensure you have the following installed on your system:
  • .NET 10.0 SDK - Required for building and running the application
  • SQLite - Lightweight database for local development
  • Git - For cloning the repository

Verify .NET Installation

Check your .NET SDK version:
dotnet --version
You should see version 10.0.x or higher.

Installation Steps

1

Clone the repository

Clone the Social Media Activity Feed API repository:
git clone <repository-url>
cd Social-Media-Activity-Feed
2

Restore dependencies

Install all required NuGet packages:
dotnet restore

Dependencies

The project includes the following key packages (from Social-Media-Activity-Feed.csproj):
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.1" />
Key dependencies:
  • Microsoft.EntityFrameworkCore.Sqlite - Database provider for SQLite
  • Microsoft.AspNetCore.Authentication.JwtBearer - JWT authentication middleware
  • Microsoft.EntityFrameworkCore.Tools - EF Core command-line tools for migrations

Configuration

JWT Settings

Configure JWT authentication using .NET user secrets for secure credential storage:
dotnet user-secrets init
dotnet user-secrets set "Jwt:Issuer" "YourIssuerName"
dotnet user-secrets set "Jwt:Key" "YourSecureSecretKeyHere"
User secrets are stored outside your project directory and are never committed to source control. This is the recommended approach for local development.
JWT Configuration Requirements:
  • Jwt:Issuer - The issuer name for token validation (e.g., “SocialMediaAPI”)
  • Jwt:Key - A secure secret key for signing tokens (minimum 32 characters recommended)

Database Connection String

The application is configured to use SQLite with the following connection string (from Program.cs):
options.UseSqlite("Data Source = social.db")
This creates a SQLite database file named social.db in your project root directory.

Application Settings

The appsettings.json file contains logging and host configuration:
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}
JWT settings are intentionally not stored in appsettings.json for security. Always use user secrets for local development and environment variables or secure vaults for production.

Database Setup

Install EF Core Tools

If you haven’t installed Entity Framework Core tools globally:
dotnet tool install --global dotnet-ef

Run Migrations

Create and initialize the database:
dotnet ef database update
This command:
  1. Creates the social.db SQLite database file
  2. Applies all migrations to create the schema
  3. Sets up tables for Users, Follows, Posts, Notifications, and more

View Available Migrations

To see all available migrations:
dotnet ef migrations list

Verification

Verify your installation by running the application:
dotnet run
Expected output:
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.

Test the API

Check if the API is running:
curl http://localhost:5000/
Response:
Hello World!
Use a SQLite browser tool like DB Browser for SQLite to inspect and debug your database during development.

Troubleshooting

Missing JWT Configuration

If you see authentication errors, ensure JWT settings are configured:
dotnet user-secrets list
You should see:
Jwt:Issuer = YourIssuerName
Jwt:Key = YourSecureSecretKeyHere

Database Connection Issues

If the database fails to connect:
  1. Ensure the social.db file has write permissions
  2. Run dotnet ef database update to recreate the database
  3. Check for migration errors in the console output

Port Already in Use

If port 5000 or 5001 is already in use, specify a different port:
dotnet run --urls "http://localhost:5050;https://localhost:5051"

Next Steps

Now that you have the API installed:

Build docs developers (and LLMs) love