Skip to content

saikat455/weather-mood

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Weather Mood Journal API 🌦️

A .NET Core Web API that tracks daily mood entries with weather data correlation and provides analytics on mood patterns.

Features

  • User Authentication with JWT tokens
  • Daily Mood Logging (1-10 scale) with notes
  • Real-time Weather Integration via OpenWeather API
  • Mood Analytics showing correlations between mood and weather
  • PostgreSQL Database with Entity Framework Core
  • RESTful API with Swagger documentation

Tech Stack

  • .NET 8 Web API
  • PostgreSQL database
  • Entity Framework Core ORM
  • JWT Authentication
  • OpenWeather API integration
  • BCrypt password hashing
  • System.Text.Json for JSON handling

Prerequisites

  • .NET 8 SDK
  • PostgreSQL
  • OpenWeather API key (free)

Quick Start

  1. Clone and setup

    git clone https://github.com/saikat455/weather-mood.git
    cd WeatherMoodJournal.API
    dotnet restore
  2. Configure settings in appsettings.json:

    {
      "ConnectionStrings": {
        "DefaultConnection": "Host=localhost;Database=WeatherMoodJournal;Username=postgres;Password=your_password"
      },
      "WeatherAPI": {
        "ApiKey": "your-openweather-api-key"
      }
    }
  3. Database setup

    dotnet ef database update
  4. Run the application

    dotnet run
  5. Test API at https://localhost:7xxx/swagger

API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user

Mood Entries

  • POST /api/mood - Create mood entry with weather data
  • GET /api/mood - Get user's mood entries (paginated)
  • GET /api/mood/{id} - Get specific mood entry
  • DELETE /api/mood/{id} - Delete mood entry
  • GET /api/mood/analytics - Get mood vs weather analytics

Sample Analytics Response

{
  "totalEntries": 15,
  "averageMood": 7.2,
  "moodByWeather": [
    {
      "weatherCondition": "Clear",
      "averageMood": 8.5,
      "entryCount": 8
    }
  ],
  "moodByTemperatureRange": [
    {
      "temperatureRange": "Warm (20-30°C)",
      "averageMood": 8.0,
      "entryCount": 6
    }
  ]
}

What I Learned & Challenges I Overcame

Core Learning Outcomes

  • JWT Authentication Implementation - I learned token-based security
  • External API Integration - I consumed third-party APIs (OpenWeather)
  • Database Relationships - I designed User-MoodEntry one-to-many relationship
  • Entity Framework Core - I practiced code-first migrations, LINQ queries
  • Password Security - I implemented BCrypt hashing and validation
  • RESTful API Design - I applied proper HTTP methods and status codes

Technical Challenges I Faced

  • Async Programming - I handled multiple async operations (DB + API calls)
  • Error Handling - I managed graceful handling of external API failures
  • Data Analytics - I wrote complex LINQ queries for mood-weather correlations
  • Authentication Flow - I secured endpoints with JWT middleware
  • Configuration Management - I handled sensitive data (API keys, connection strings)

Real-World Skills I Developed

  • API Security - I protected user data with proper authentication
  • Third-Party Integration - I worked with external services and handled failures
  • Database Design - I created normalized, efficient database schema
  • JSON Handling - I parsed and serialized complex data structures
  • Deployment Readiness - I structured code for production environments

About

A .NET Core Web API that tracks daily mood entries with weather data correlation and provides analytics on mood patterns.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages