AEMET repositorio
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| .opencode/plans | ||
| public | ||
| src | ||
| test/context/Weather/domain | ||
| .dockerignore | ||
| .editorconfig | ||
| .gitignore | ||
| .prettierrc.json | ||
| .stylelintrc.json | ||
| AGENTS.md | ||
| bun.lock | ||
| components.json | ||
| compose.yaml | ||
| Dockerfile | ||
| Dockerfile.prod | ||
| eslint.config.mjs | ||
| FORGEJO_HOOK.md | ||
| HOOK_SETUP.md | ||
| LICENSE | ||
| Makefile | ||
| MIGRATION_COMPLETE.md | ||
| next-env.d.ts | ||
| next.config.ts | ||
| package.json | ||
| postcss.config.mjs | ||
| README.md | ||
| sonar-project.properties | ||
| tailwind.config.ts | ||
| tsconfig.json | ||
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/clientandprismapackages
Key Files
src/lib/dbPool.ts- Database connection poolsrc/context/Weather/infrastructure/sql-weather-repository.ts- Weather SQL repositorysrc/context/Event/infrastructure/sql-event-repository.ts- Event SQL repositorysrc/types/weather.ts- Weather type definitionssrc/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
mainbranch 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.