Skip to content

metakgp/cfmn

Repository files navigation

Contributors Forks Stargazers Issues MIT License Wiki


image

CFMN: Can't Find My Notes

No more venturing into dark alleys
Website · Request Feature / Report Bug

Table of Contents

About The Project

[WIP]

Getting Started

[WIP]

Prerequisites

[WIP]

Environment Setup

This project requires proper environment configuration for both development and production environments. Environment files contain sensitive configuration like API keys, database credentials, and other settings.

Setting up Development Environment (.env)

  1. Copy the template file:

    cp .env.template .env
  2. Configure the environment variables in .env:

    # Google OAuth - Get this from Google Cloud Console (see Google OAuth Setup section)
    GOOGLE_CLIENT_ID=your_actual_client_id.apps.googleusercontent.com
    
    # JWT Configuration - Generate a secure random string
    SIGNING_SECRET=your-secure-signing-secret-here
    EXPIRATION_TIME_SECONDS="86400"  # 24 hours
    
    # File Upload Configuration
    FILE_SIZE_LIMIT="50"  # MB
    
    # Server Configuration
    PORT=8085
    
    # Database Configuration (for local development)
    DB_NAME=cfmn_dev
    DB_HOST=localhost  # Should be localhost for development
    DB_PORT=5432
    DB_USER=cfmn_user
    DB_PASSWORD=cfmn_password
    
    # File Storage Paths (create these directories locally)
    UPLOADED_NOTES_PATH=cfmn/notes/uploaded
    PREVIEWS_PATH=cfmn/previews/uploaded
    LOG_LOCATION=/path/to/your/log/directory
    
    # Static Files Configuration
    STATIC_FILES_URL=http://localhost:8085
    STATIC_FILE_STORAGE_LOCATION=/path/to/your/static/files

Setting up Production Environment (.production.env)

  1. Copy the template file:

    cp .production.env.template .production.env
  2. Configure the environment variables in .production.env:

    # Google OAuth - Same as development but for production domain
    GOOGLE_CLIENT_ID=your_production_client_id.apps.googleusercontent.com
    
    # JWT Configuration - Use a different, secure signing secret for production
    SIGNING_SECRET=your-production-signing-secret-here
    EXPIRATION_TIME_SECONDS="86400"
    
    # File Upload Configuration
    FILE_SIZE_LIMIT="50"
    
    # Server Configuration
    PORT=8085
    VITE_API_BASE_URL=https://your-production-api-url.com
    FRONTEND_BUILD_DIR=../frontend/dist/
    
    # Database Configuration (for production)
    DB_NAME=cfmn_production
    DB_HOST=postgres  # Docker service name or production database host
    DB_PORT=5432
    DB_USER=your_production_db_user
    DB_PASSWORD=your_production_db_password
    
    # File Storage Paths (production paths)
    UPLOADED_NOTES_PATH=cfmn/notes/uploaded
    PREVIEWS_PATH=cfmn/previews/uploaded
    
    # Static Files Configuration (production)
    STATIC_FILES_URL=http://static.metakgp.org
    
    # Docker Container Paths
    LOG_LOCATION=/app/log
    STATIC_FILE_STORAGE_LOCATION=/app/static_files

Frontend Environment Setup

The frontend also requires environment configuration:

For Development (frontend/.env.local):

VITE_GOOGLE_CLIENT_ID=your_actual_client_id.apps.googleusercontent.com
VITE_API_BASE_URL=http://localhost:8085

For Production (frontend/.env.production):

VITE_GOOGLE_CLIENT_ID=your_production_client_id.apps.googleusercontent.com
VITE_API_BASE_URL=https://your-production-api-url.com

Important Notes

  • Never commit actual environment files (.env, .production.env) to version control
  • Generate secure, random signing secrets for production environments
  • Use different Google OAuth Client IDs for development and production
  • Ensure database credentials match your actual database configuration
  • Create required directories specified in file paths before running the application

Google OAuth Setup

This project requires Google OAuth for authentication. You need to set up a Google OAuth client and configure the client ID in multiple environment files.

Step 1: Create Google OAuth Credentials

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Navigate to APIs & Services > Credentials
  4. Click Create Credentials > OAuth client ID
  5. If prompted, configure the OAuth consent screen first:
  • Choose External user type
  • Fill in the required fields (App name, User support email, Developer contact email)
  • Add your domain to Authorized domains if deploying to production
  1. For Application type, select Web application
  2. Add your Authorized Javascript origins:
  • For development: http://localhost:5173 and http://localhost
  • For production: https://cfmn.metakgp.org (frontend URL)
  1. Click Create and copy the Client ID. Client Secret is not needed for this project.

Step 2: Configure Environment Variables

You need to set the Google Client ID in the following environment files:

Frontend Environment Files:

  • frontend/.env.local (for development)
  • frontend/.env.production (for production builds)
VITE_GOOGLE_CLIENT_ID=your_google_client_id_here

Root Environment Files:

  • project_root/.env (for development)
  • project_root/.production.env (for production)
GOOGLE_CLIENT_ID=your_google_client_id_here

Step 3: Verify Configuration

Make sure all four files contain the correct Google Client ID:

  • Frontend uses VITE_GOOGLE_CLIENT_ID (Vite environment variable)
  • Backend/root uses GOOGLE_CLIENT_ID (standard environment variable)

Database Setup

This project uses a PostgreSQL database. The database schema and initial data are defined in project_root/database/init.sql.

Development Environment

For development, the database is automatically set up using Docker Compose:

  1. Configure database parameters in docker-compose.dev.yml:

    services:
      postgres:
        image: postgres:16-alpine
        container_name: cfmn-dev-db
        environment:
          POSTGRES_DB: cfmn_dev
          POSTGRES_USER: cfmn_user
          POSTGRES_PASSWORD: cfmn_password
        volumes:
          - ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
          - postgres-data-dev:/var/lib/postgresql/data
        ports:
          - "5432:5432"
    
    volumes:
      postgres-data-dev:
        name: postgres-data-dev
  2. The database will be automatically initialized when you run:

    docker-compose -f docker-compose.dev.yml up
  3. Database initialization includes:

  • Creating tables and schemas defined in project_root/database/init.sql
  • Setting up initial data
  • Configuring database constraints and indexes
  • All queries in init.sql are executed automatically on first startup

Production Environment

For production deployment, you need to manually set up the database:

  1. Create a PostgreSQL database (probably Database of Babel)

  2. Execute the initialization queries from project_root/database/init.sql:

    psql -h your_host -U your_user -d your_database -f project_root/database/init.sql
  3. Configure your production environment variables with the database connection details:

    DATABASE_URL=postgresql://username:password@host:port/database
    # or individual parameters
    DB_HOST=your_database_host
    DB_PORT=5432
    DB_NAME=your_database_name
    DB_USER=your_database_user
    DB_PASSWORD=your_database_password

Database Schema

The project_root/database/init.sql file contains:

  • Table definitions for users, notes and votes
  • Foreign key constraints and relationships

Make sure to review and customize the database configuration based on your specific requirements.

Installation

[WIP]

Usage

[WIP]

Contact

📫 Metakgp - Metakgp's slack invite Metakgp's email metakgp's Facebook metakgp's LinkedIn metakgp's Twitter metakgp's Instagram

Maintainer(s)

The currently active maintainer(s) of this project.

Creator(s)

Honoring the original creator(s) and ideator(s) of this project.

(back to top)

Additional documentation

(back to top)