AEMET repositorio
Find a file
JPerera ea2773fd01
All checks were successful
bun test / test (push) Successful in 26s
test
2026-02-01 17:28:21 +01:00
.forgejo/workflows forgejo actions 2026-02-01 17:11:45 +01:00
.opencode/plans test 2026-02-01 17:28:21 +01:00
public test 2026-02-01 15:42:37 +01:00
src test 2026-02-01 17:28:21 +01:00
test/context/Weather/domain test 2026-02-01 17:28:21 +01:00
.dockerignore dotfiles 2026-02-01 15:46:48 +01:00
.editorconfig dotfiles 2026-02-01 15:46:48 +01:00
.gitignore test 2026-02-01 17:28:21 +01:00
.prettierrc.json dotfiles 2026-02-01 15:46:48 +01:00
.stylelintrc.json dotfiles 2026-02-01 15:46:48 +01:00
AGENTS.md test 2026-02-01 17:28:21 +01:00
bun.lock test 2026-02-01 17:28:21 +01:00
components.json test 2026-02-01 15:42:37 +01:00
compose.yaml test 2026-02-01 15:42:37 +01:00
Dockerfile test 2026-02-01 15:42:37 +01:00
Dockerfile.prod test 2026-02-01 15:42:37 +01:00
eslint.config.mjs test 2026-02-01 15:42:37 +01:00
FORGEJO_HOOK.md test 2026-02-01 17:28:21 +01:00
HOOK_SETUP.md test 2026-02-01 17:28:21 +01:00
LICENSE Initial commit 2026-02-01 15:37:55 +01:00
Makefile test 2026-02-01 15:42:37 +01:00
MIGRATION_COMPLETE.md test 2026-02-01 17:28:21 +01:00
next-env.d.ts test 2026-02-01 17:28:21 +01:00
next.config.ts test 2026-02-01 15:42:37 +01:00
package.json test 2026-02-01 17:28:21 +01:00
postcss.config.mjs test 2026-02-01 15:42:37 +01:00
README.md test 2026-02-01 17:28:21 +01:00
sonar-project.properties test 2026-02-01 15:42:37 +01:00
tailwind.config.ts test 2026-02-01 15:42:37 +01:00
tsconfig.json test 2026-02-01 15:42:37 +01:00

AEMET Weather Visualizer

A Next.js application for visualizing weather data with PostgreSQL backend.

Features

  • Weather data visualization with interactive charts
  • PostgreSQL database integration
  • Real-time data fetching from AEMET API
  • OpenTelemetry observability
  • Prisma to Bun SQL migration

Getting Started

Prerequisites

  • Node.js 18+ or Bun
  • PostgreSQL database
  • Git

Installation

# Install dependencies
npm install
# or
bun install

# Set up environment variables
cp .env.example .env
# Edit .env with your DATABASE_URL

Running the Application

# Development server
npm run dev
# or
bun dev

# Production build
npm run build
npm start

The application will be available at http://localhost:3000.

Project Structure

src/
├── context/
│   ├── Weather/
│   │   ├── domain/          # Weather domain logic and types
│   │   ├── application/     # Weather use cases
│   │   └── infrastructure/  # Weather repositories (SQL-based)
│   └── Event/
│       ├── domain/          # Event domain logic and types
│       └── infrastructure/  # Event repositories (SQL-based)
├── app/                     # Next.js app router pages
├── components/              # React components
├── lib/                     # Utility functions
└── types/                   # TypeScript type definitions

Migration from Prisma to Bun SQL

This project has been migrated from Prisma ORM to raw PostgreSQL using the pg driver.

What Changed

  • Database Layer: Replaced PrismaClient with PostgreSQL Pool in src/lib/dbPool.ts
  • Repositories: Created SQL-based repositories using raw queries
  • Type Definitions: Local type definitions in src/types/
  • Dependencies: Removed @prisma/client and prisma packages

Key Files

  • src/lib/dbPool.ts - Database connection pool
  • src/context/Weather/infrastructure/sql-weather-repository.ts - Weather SQL repository
  • src/context/Event/infrastructure/sql-event-repository.ts - Event SQL repository
  • src/types/weather.ts - Weather type definitions
  • src/types/event.ts - Event type definitions

See MIGRATION_COMPLETE.md for detailed migration information.

Git Hooks

This repository includes a Forgejo git hook that logs pushes to the main branch.

Hook Details

  • Location: .git/hooks/pre-receive
  • Function: Logs all pushes to main branch to console and log file
  • Information Captured:
    • Timestamp
    • Branch name
    • Commit hash
    • Author name
    • Commit message

Example Output

========================================
[2026-02-01 16:45:23] Git push detected on main
  Commit: a3f2b1c
  Author: John Doe <john@example.com>
  Message: Refactor: Migrate from Prisma to Bun SQL
========================================

Log File

  • Console: Real-time output during push
  • File: /tmp/forgejo-hook.log (persistent record)

See FORGEJO_HOOK.md for detailed hook documentation.

Code Style

This project follows TypeScript with strict mode and follows the code style guidelines in AGENTS.md:

  • Language: TypeScript with strict mode
  • Format: Single quotes, semicolons, 2-space indentation
  • Naming: camelCase for functions, PascalCase for components
  • Organization: Domain-Driven Design with context-based structure

Database Schema

Weather Table

  • date (DateTime, primary key, unique)
  • temp (Float, nullable)
  • wind (Float, nullable)
  • wind_dir (String, nullable)
  • gust (Float, nullable)
  • gust_dir (String, nullable)
  • rain (Float, nullable)
  • pressure (Float, nullable)
  • pressure_delta (Float, nullable)
  • humidity (Float, nullable)

Event Table

  • date (DateTime)
  • id (String, primary key)
  • parent (String, nullable)
  • name (String)
  • level (String)
  • payload (Json, nullable)

Environment Variables

DATABASE_URL=postgresql://user:password@host:port/database
PORT=3000

Testing

# Run lint
npm run lint

# Format code
npm run prettier

Deployment

This project is ready for deployment on Vercel or any other Next.js hosting platform.

Contributing

When pushing to this repository, the git hook will log all commits to the main branch to the console and log file.

License

See LICENSE for details.

Resources