Skip to content

Pictoreal-Organization/CCA-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

123 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PictoCreds Backend API

Pictoreal CCA Management System

A comprehensive backend system powering the PictoCreds mobile app for managing meetings, tasks, attendance, teams, and user authentication with real-time notifications.

πŸš€ Features

  • Authentication & Authorization

    • JWT-based authentication
    • Google OAuth integration
    • Role-based access control (Admin/User)
    • Password reset with OTP verification
    • FCM token management for push notifications
  • Meeting Management

    • Create, update, and delete meetings
    • Meeting scheduling and notifications
    • Automated meeting reminders (via cron jobs)
  • Task Management

    • Task creation and assignment
    • Task tracking and status updates
  • Attendance Tracking

    • Attendance logging and management
    • Attendance reports
  • Team Collaboration

    • Team creation and management
    • Team member management
  • Tag System

    • Categorization with tags
    • Tag-based filtering

πŸ“‹ Prerequisites

  • Node.js (v14 or higher)
  • MongoDB
  • Firebase account (for push notifications)
  • Google OAuth credentials (optional, for Google login)

πŸ› οΈ Installation

  1. Clone the repository
   git clone https://github.com/Pictoreal-Organization/CCA-backend
   cd cca-backend
  1. Install dependencies
   npm install
  1. Environment Setup

    Create a .env file in the root directory:

   PORT=5001
   MONGODB_URI=your_mongodb_connection_string
   JWT_SECRET=your_jwt_secret
   JWT_REFRESH_SECRET=your_refresh_token_secret
   
   # Email Configuration (for OTP)
   EMAIL_USER=your_email@example.com
   EMAIL_PASSWORD=your_email_password
   
   # Google OAuth
   GOOGLE_CLIENT_ID=your_google_client_id
   GOOGLE_CLIENT_SECRET=your_google_client_secret
   
   # Firebase Admin SDK
   FIREBASE_PROJECT_ID=your_project_id
   FIREBASE_PRIVATE_KEY=your_private_key
   FIREBASE_CLIENT_EMAIL=your_client_email
   
   # Keep-Alive URL (for Render.com or similar)
   BACKEND_URL=https://your-backend-url.com/dummy
  1. Firebase Service Account Setup

    Create a firebase-service-account.json file in the root directory with your Firebase Admin SDK credentials:

   {
     "type": "service_account",
     "project_id": "your-project-id",
     "private_key_id": "your-private-key-id",
     "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
     "client_email": "firebase-adminsdk-xxxxx@your-project.iam.gserviceaccount.com",
     "client_id": "your-client-id",
     "auth_uri": "https://accounts.google.com/o/oauth2/auth",
     "token_uri": "https://oauth2.googleapis.com/token",
     "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
     "client_x509_cert_url": "your-cert-url"
   }

πŸ“Œ Note: This file is gitignored for security. Download it from your Firebase Console β†’ Project Settings β†’ Service Accounts

  1. Seed the database (optional)

    Populate the database with Pictoreal team members from CSV files. See Database Seeding section below for detailed instructions.

   npm run seed
  1. Generate Swagger documentation
   npm run swagger

🚦 Running the Application

Development Mode

npm run dev

Production Mode

npm start

The server will start on http://localhost:5001

πŸ—„οΈ Database Seeding

To populate the database with Pictoreal team members from CSV files:

  1. Ensure CSV files are present in the All_csvs/ folder:

    • core_team.csv - Contains core team/heads information
    • members.csv - Contains member information
  2. Run the seed command:

npm run seed

This will automatically:

  • Import all core team members and heads from core_team.csv
  • Import all regular members from members.csv
  • Create necessary teams and assign members
  • Set initial passwords (username from email)

⚠️ Note: Verify CSV data before running seed command. The script will create/update users and teams based on CSV content.

πŸ“ Project Structure

cca-backend/
β”œβ”€β”€ controllers/                    # Business logic for each route
β”œβ”€β”€ models/                         # MongoDB schemas
β”œβ”€β”€ routes/                         # API route definitions
β”œβ”€β”€ middlewares/                    # Custom middleware (auth, validation, etc.)
β”œβ”€β”€ cron/                           # Scheduled jobs (meeting reminders, etc.)
β”œβ”€β”€ config/                         # Configuration files
β”œβ”€β”€ All_csvs/                       # CSV files containing Pictoreal team member data
β”‚   └── *.csv                       # Team member information (check before seeding)
β”œβ”€β”€ importCoreTeam.js               # Script to import core team/heads into database
β”œβ”€β”€ importMembers.js                # Script to import members into database
β”œβ”€β”€ db.js                           # Database connection
β”œβ”€β”€ index.js                        # Application entry point
β”œβ”€β”€ swagger-init.js                 # Swagger documentation generator
β”œβ”€β”€ seed.js                         # Database seeding script
β”œβ”€β”€ firebase-service-account.json   # Firebase Admin SDK credentials (gitignored)
└── .env                            # Environment variables (gitignored)

Important Files to Configure

Before running the application, ensure these files are properly set up:

  • All_csvs/ folder - Contains CSV files with Pictoreal team member data. Verify the data is up-to-date before importing.
  • importCoreTeam.js - Run this to add team heads/core members to the database
  • importMembers.js - Run this to add regular members to the database
  • firebase-service-account.json - Required for Firebase push notifications (download from Firebase Console)

πŸ“š API Documentation

Once the server is running, access the interactive API documentation at:

http://localhost:5001/docs

The Swagger UI provides complete details for all endpoints including:

  • Request/response schemas
  • Authentication requirements
  • Example requests
  • Try-it-out functionality

Available API Modules

The API is organized into the following modules:

  • Authentication (/api/auth) - User authentication, registration, login, password management, and OAuth
  • Meetings (/api/meetings) - Meeting creation, scheduling, updates, and automated reminders
  • Tasks (/api/tasks) - Task management, assignment, and status tracking
  • Users (/api/user) - User profile management and user-related operations
  • Admin (/api/admin) - Administrative operations (requires admin privileges)
  • Attendance (/api/attendance) - Attendance logging, tracking, and reporting
  • Teams (/api/teams) - Team creation, management, and collaboration features
  • Tags (/api/tags) - Tag-based categorization and filtering system

πŸ’‘ Tip: Visit /docs endpoint after starting the server to explore all available routes with detailed documentation.

πŸ” Authentication

The API uses JWT (JSON Web Tokens) for authentication. Include the token in the Authorization header:

Authorization: Bearer <your_jwt_token>

Role-Based Access Control

  • Admin: Full access to all endpoints
  • User: Limited access based on permissions

πŸ“¦ Dependencies

Core Dependencies

  • express - Web framework
  • mongoose - MongoDB ODM
  • jsonwebtoken - JWT authentication
  • bcrypt - Password hashing
  • cors - Cross-origin resource sharing
  • dotenv - Environment variable management

Authentication & Security

  • google-auth-library - Google OAuth
  • firebase-admin - Firebase push notifications

Utilities

  • node-cron - Scheduled tasks
  • nodemailer - Email sending
  • morgan - HTTP request logger
  • axios - HTTP client
  • csv-parser - Parse CSV files for member imports

Documentation

  • swagger-autogen - Auto-generate Swagger docs
  • swagger-ui-express - Swagger UI interface

πŸ”„ Cron Jobs

The application runs automated tasks using node-cron:

  • Meeting Reminders: Sends notifications for upcoming meetings
  • Keep-Alive Ping: Prevents server sleep on free hosting (runs every 10 minutes)

πŸ§ͺ Testing

npm test

🌐 Deployment

The application is configured for deployment on platforms like Render.com, Heroku, or similar.

Important Notes:

  • The keep-alive mechanism pings the server every 10 minutes to prevent cold starts
  • Update BACKEND_URL in .env with your production URL
  • Ensure all environment variables are set in your hosting platform
  • Upload firebase-service-account.json securely to your hosting platform

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ Scripts

  • npm run dev - Start development server with nodemon
  • npm run swagger - Generate Swagger documentation
  • npm run seed - Seed database with initial data
  • npm test - Run tests

⚠️ Common Issues

MongoDB Connection Issues

  • Ensure MongoDB is running
  • Check MONGODB_URI in .env
  • Whitelist your IP in MongoDB Atlas (if using cloud)

Swagger Not Loading

  • Run npm run swagger to regenerate documentation
  • Restart the server

FCM Notifications Not Working

  • Verify Firebase credentials in .env
  • Ensure firebase-service-account.json is properly configured
  • Check that FCM tokens are properly saved

CSV Import Issues

  • Verify CSV files in All_csvs/ folder are properly formatted
  • Check that CSV headers match expected format
  • Run importCoreTeam.js and importMembers.js in the correct order

πŸ“„ License

ISC

πŸ‘₯ Authors

Riddhi Lahare
Riddhi Lahare
Manas Gawali
Manas Gawali
Madhura Deshmukh
Madhura Deshmukh

πŸ“§ Contact

For issues or questions, please contact pictorealcca@gmail.com


Made with ❀️ by the Pictoreal Team

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors