Skip to content

german-cueto07/HackMTYAPIwebapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 

Repository files navigation

Billy Web API (HackMTY API Webapp)

Part of the Billy ecosystem.

Project Links: CRM for Billy App (Frontend)API for Billy Web (this repo)API for Billy AI (LocalAI/Ollama)


Project Overview

This repository provides the backend API for the CRM for Billy App, serving as the main business logic and data layer of the system. Built with TypeScript + Express + MySQL, it exposes endpoints for products, employees, users, sales, purchases, analytics, and taxes. Additionally, it integrates with the Billy AI API to extend conversational intelligence and summarization features to the frontend application.

Swagger documentation is included for quick endpoint exploration.


Key Files and Structure

src/
├── index.ts          # App entry: server, middleware, routes
├── config.ts         # Environment variables and constants
├── db/connection.ts  # MySQL connection helper
├── routes/           # REST endpoint definitions under /api
├── controllers/      # Business logic for each resource
├── middleware/       # (Future) Authentication / validation layers
├── utils/            # Helper utilities
└── database_update.sql  # SQL schema and seed data

Integration with the Billy Ecosystem

This API is the core backend that connects the CRM for Billy App frontend with persistent storage and analytics capabilities.

  • Frontend Communication: All CRUD operations for products, employees, and sales are consumed by the React frontend.
  • AI Layer Communication: The /api/chatbot/insert-text endpoint connects directly to the Billy AI API, forwarding conversation inputs for summarization and context processing.
  • Analytics: Endpoints such as /api/ingresos/totales and /api/crecimiento feed visual data to the analytics module in the main app.

Requirements

  • Node.js 18+
  • npm, pnpm, or yarn
  • A running MySQL instance (local or remote)

Environment Variables

Example .env configuration:

DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=hackmty
DB_PORT=3306
PORT=3000

Ensure this server runs before starting the CRM for Billy App. For AI-driven endpoints, also start the Billy AI API.


Installation & Running

npm install
npm run dev        # Development (nodemon + ts-node)
npm run build      # Compile TypeScript to /dist
npm start          # Run production build

When started, the server logs:

🚀 Server running on port <PORT>

API Documentation (Swagger)

Swagger UI available at: ➡️ http://localhost:/api-docs (Default: http://localhost:3000/api-docs)


Endpoints Overview

Products

CRUD endpoints under /api/productos.

Employees

Manage employee records under /api/empleados.

Users (Profiles)

User management endpoints under /api/usuarios.

Sales & Purchases

Record and retrieve transactions under /api/ventas and /api/compras.

Analytics & Helpers

Provide insights for the CRM for Billy App:

  • /api/ingresos/totales — total income.
  • /api/egresos/totales — total expenses.
  • /api/crecimiento — growth over custom date range.
  • /api/impuestos/calcular — calculate monthly taxes.

AI Integration Endpoint

Connects to Billy AI API:

  • POST /api/chatbot/insert-text — forwards conversation text for processing.

Database Setup

Use database_update.sql to initialize or update the schema:

mysql -u root -p hackmty < ./database_update.sql

You can also run it using GUI tools like DBeaver or MySQL Workbench.


Example Requests

Get All Products

curl http://localhost:3000/api/productos

Create a Product

curl -X POST http://localhost:3000/api/productos -H "Content-Type: application/json" -d '{"nombre":"Producto A","precio":100.0,"stock":50}'

AI Chat Integration

curl -X POST http://localhost:3000/api/chatbot/insert-text -H "Content-Type: application/json" -d '{"texto":"Hoy vendimos 20 unidades de producto B"}'

Logging & Error Handling

  • Logs startup and endpoint access to the console.
  • Returns structured JSON errors (4xx and 5xx) for easy debugging.

Development Notes

  • Future plans include integrating authentication, role-based access, and automated tests (Jest/Vitest).
  • A future Docker Compose setup could orchestrate MySQL + both APIs (Billy Web API + Billy AI API) for easier deployment.

Contributing

  1. Fork this repo.
  2. Create a branch (git checkout -b feature/YourFeature).
  3. Commit your changes.
  4. Push to your branch and open a PR.

To test features end-to-end, link your local clone with the CRM for Billy App frontend and the Billy AI API.


License

Licensed under the ISC License — see package.json.


README updated for integration with the full Billy project — (CRM Frontend + Web API + AI API) — on October 26, 2025.

About

API para gestionar la API de la pagina web y aplicacion movil

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •