Skip to content

PFEPLTechHub/code-generator

Repository files navigation

Code Generator Tool

A web application for generating project codes in PFEPL format with document upload capability.

Features

  • Project Selection: Choose from a dropdown of available projects
  • Code Generation: Generate codes in the format PFEPL/YY-YY/PROJECT_CODE/XXXX
  • Document Upload: Upload related documents after code generation
  • Modern UI: Clean, responsive interface with gradient backgrounds

Code Format

The generated codes follow this format:

  • PFEPL: Constant prefix
  • YY-YY: Financial year (auto-calculated based on current date)
  • PROJECT_CODE: Selected project code from dropdown
  • XXXX: Incremental number (0001, 0002, etc.)

Example: PFEPL/25-26/UVRILP/0001

Setup Instructions

Prerequisites

  • Node.js (version 14 or higher)
  • npm or yarn

Installation

  1. Install dependencies:

    npm install
  2. Create an .env file in the project root:

    MYSQL_HOST=127.0.0.1
    MYSQL_PORT=3306
    MYSQL_USER=root
    MYSQL_PASSWORD=your_password_here
    MYSQL_DATABASE=code_genrator
  3. Start the backend server:

    npm start

    This will start the Express server on port 3001.

  4. Start the frontend development server (in a new terminal):

    npm run dev

    This will start the Vite development server on port 5173.

  5. Access the application: Open your browser and navigate to http://localhost:5173

Usage

  1. Generate Code:

    • Select a project from the dropdown
    • Enter a reason for generation
    • Click "Generate Code"
    • The system will display the generated code
  2. Upload Document:

    • After generating a code, you can upload a related document
    • Click "Choose file to upload" and select your document
    • Click "Upload Document" to attach it to the generated code

Sample Projects

The application comes with pre-loaded sample projects:

  • Urban Village Infrastructure (UVRILP)
  • Smart City Development (SCD)
  • Digital Transformation (DIGIT)
  • Green Energy Initiative (GEI)
  • Healthcare Modernization (HCM)

Technical Details

Backend

  • Express.js server with SQLite database
  • RESTful API endpoints for projects, code generation, and file uploads
  • Multer for handling file uploads
  • CORS enabled for frontend communication

Frontend

  • React 18 with functional components and hooks
  • Vite for fast development and building
  • Modern CSS with gradients and animations
  • Responsive design that works on all devices

Database Schema

  • projects: Stores project information (name, code)
  • generated_codes: Stores generated codes with metadata and document paths

API Endpoints

  • GET /api/projects - Get all available projects
  • POST /api/generate-code - Generate a new code
  • POST /api/upload-document - Upload a document for a generated code

File Structure

├── src/
│   ├── components/
│   │   └── CodeGenerator.jsx
│   ├── App.jsx
│   ├── main.jsx
│   └── index.css
├── database.js
├── server.js
├── package.json
├── vite.config.js
└── README.md

Development

To modify the application:

  1. Add new projects: Edit the insertSampleProjects() function in database.js
  2. Modify code format: Update the code generation logic in server.js
  3. Change UI: Modify the React components in src/components/
  4. Update styling: Edit src/index.css

Production Deployment

  1. Build the frontend:

    npm run build
  2. Serve static files: Update server.js to serve the built files from the dist directory

  3. Set environment variables: Configure production database and file storage paths

License

This project is open source and available under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published