ACIKY-backend
🧘 ACIKY Backend API
Section titled “🧘 ACIKY Backend API”REST API backend for ACIKY (Asociación Cubana de Instructores de Kundalini Yoga) website content management system.
🚀 Features
Section titled “🚀 Features”- Authentication System - Secure login/register with session management
- Role-Based Access Control - Admin, Instructor, and User roles
- Content Management - CRUD operations for:
- Blog posts
- Activities/Classes
- Routes (Rutas Doradas)
- Testimonials
- Events
- Gallery
- FAQs
- Contact messages
- RESTful API - Clean, documented endpoints
- MySQL Database - Relational data storage
- CORS Enabled - Frontend integration ready
📋 Prerequisites
Section titled “📋 Prerequisites”- Node.js (v14 or higher)
- MySQL (v8 or higher)
- npm or yarn
🛠️ Installation
Section titled “🛠️ Installation”-
Clone the repository
Terminal window git clone https://github.com/camachoeng/ACIKY.gitcd yoga-backend -
Install dependencies
Terminal window npm install -
Configure environment variables
Create a
.envfile in the root directory:# Database ConfigurationDB_HOST=localhostDB_USER=rootDB_PASSWORD=your_passwordDB_NAME=yoga_dbDB_PORT=3306# Server ConfigurationPORT=3000SESSION_SECRET=your_secret_key_here -
Set up the database
Run the SQL migration scripts in MySQL Workbench or command line in this order:
- Create the database schema
- Run migrations for all tables
- Insert initial data
-
Create an admin user
UPDATE users SET role = 'admin' WHERE email = 'your-email@example.com';
🏃 Running the Server
Section titled “🏃 Running the Server”Development Mode
Section titled “Development Mode”npm run devProduction Mode
Section titled “Production Mode”npm startThe server will run at http://localhost:3000
📚 API Documentation
Section titled “📚 API Documentation”See API-DOCUMENTATION.md for complete endpoint reference.
Quick Reference
Section titled “Quick Reference”Public Endpoints
Section titled “Public Endpoints”GET /api/blog- Get all blog postsGET /api/blog/:slug- Get single blog postGET /api/activities- Get all activitiesGET /api/routes- Get all routes
Authentication
Section titled “Authentication”POST /api/auth/register- Register new userPOST /api/auth/login- LoginPOST /api/auth/logout- LogoutGET /api/auth/check- Check auth status
Admin Endpoints (Requires Admin Role)
Section titled “Admin Endpoints (Requires Admin Role)”POST /api/blog- Create blog postPUT /api/blog/:id- Update blog postDELETE /api/blog/:id- Delete blog post- Similar CRUD endpoints for activities, routes, etc.
🗂️ Project Structure
Section titled “🗂️ Project Structure”yoga-backend/├── config/│ └── database.js # MySQL connection pool├── controllers/│ ├── authController.js # Authentication logic│ ├── blogController.js # Blog CRUD operations│ ├── activityController.js│ └── routeController.js├── middleware/│ └── auth.js # Auth & authorization middleware├── routes/│ ├── auth.js # Auth endpoints│ ├── blog.js # Blog endpoints│ ├── activities.js│ └── routes.js├── .env # Environment variables (not in Git)├── .gitignore├── package.json├── server.js # Express app entry point└── README.md # This file🔐 Security
Section titled “🔐 Security”- Passwords are hashed with bcrypt
- Session-based authentication with httpOnly cookies
- CORS configured for specific origins
- SQL injection prevention with parameterized queries
- Input validation on all endpoints
- Role-based access control for admin operations
🌐 CORS Configuration
Section titled “🌐 CORS Configuration”Currently configured for:
http://127.0.0.1:5500(Live Server)
For production, update server.js:
app.use(cors({ origin: 'https://your-frontend-domain.com', credentials: true}));🚢 Deployment
Section titled “🚢 Deployment”Recommended Hosting Platforms
Section titled “Recommended Hosting Platforms”- Heroku - Easy deployment with MySQL add-on
- Railway - Modern, developer-friendly
- Render - Free tier available
- DigitalOcean - Full control with App Platform
Deployment Checklist
Section titled “Deployment Checklist”- Set environment variables on hosting platform
- Update CORS origins for production domain
- Set up cloud MySQL database (ClearDB, PlanetScale, etc.)
- Configure SSL/HTTPS
- Set
NODE_ENV=production - Update frontend API URLs to production backend
🧪 Testing
Section titled “🧪 Testing”Test the API endpoints using:
- Postman
- cURL
- Browser fetch API
- Your frontend application
Example test:
fetch('http://localhost:3000/api/blog') .then(res => res.json()) .then(data => console.log(data));📦 Dependencies
Section titled “📦 Dependencies”- express - Web framework
- mysql2 - MySQL client
- bcrypt - Password hashing
- cors - Cross-origin resource sharing
- express-session - Session management
- dotenv - Environment variables
🤝 Contributing
Section titled “🤝 Contributing”- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add some AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📝 License
Section titled “📝 License”This project is private and proprietary to ACIKY.
👥 Authors
Section titled “👥 Authors”- ACIKY Team - GitHub
📧 Support
Section titled “📧 Support”For issues or questions, contact: acikyrespiray@gmail.com
Status: ✅ Production Ready
Version: 1.0.0
Last Updated: November 2025