How terufujita/bp23 works
Project Type and Purpose
• This is a full-stack “Detour Bot” application that comprises three distinct services:
1. LINE Bot server (Go) for handling Webhook events and replying to users
2. REST API server (Go + Gin) providing data access and business logic for both the bot and a web-based admin UI
3. Web management UI (Next.js) allowing administrators to view and manage routes, spots, and user history
• A shared PostgreSQL database stores users, routes, and spot data, and external route/spot search APIs (OpenRouteService, Gurunavi/HotPepper) supplement suggestions.
Directory Structure Insights
• Top-level modules:
• line-bot/
• api-server/
• web-app/
• shared/ (common types/constants)
• docs/ & scripts/ (ancillary)
• Both Go services follow a layered approach (handlers → services → repositories/models, plus pkg for config, DB, utils).
• The web-app uses Next.js 14’s “app” directory with TypeScript, CSS, and framework config files.
• Migrations and environment wrappers (.env.example) live at the root.
Key README Takeaways
• Ports:
• LINE Bot → 3001 (with ngrok in dev)
• API Server → 8080
• Web App → 3000
• External dependencies: PostgreSQL, LINE Developers credentials, optional OpenRouteService and spot-search APIs.
• Future plans: full CRUD on the API server, advanced web-UI features, shared library usage.
a. Main Components
• LINE Platform (Messaging API)
• ngrok (dev proxy for exposing Bot on 3001)
• LINE Bot Service
• External Route & Spot Search APIs
• API Server (Gin)
• PostgreSQL Database
• Web Management UI (Next.js)
• (Optionally) Shared library module & future scripts
b. Interactions & Data Flows
1. User → LINE Platform → Webhook → ngrok → LINE Bot
2. LINE Bot ↔ External APIs (route search, spot suggestions)
3. LINE Bot ↔ REST API Server (to persist or query user/route/spot data)
4. API Server ↔ PostgreSQL (CRUD operations via migrations and repository layer)
5. Web UI ↔ API Server (REST calls for display and management)
6. API Server returns responses → Web UI or LINE Bot → end user
c. Architectural Patterns
• Service separation (microservice-style): each service has a single responsibility
• Layered service design in Go modules (handlers, services, repositories, models)
• Shared schema/types in a common module for consistency across services
• Clear API boundary via REST
d. Key Technologies
• Go 1.22+, Gin, pgx/SQL migrations
• Next.js 14, TypeScript, ESLint, PostCSS
• PostgreSQL 14+, ngrok for dev
• External HTTP APIs: OpenRouteService, Gurunavi/HotPepper