Blog

  • Gold-Price-Prediction-Project-using-Machine-Learning

    Gold Price Prediction Project Using Machine Learning

    Overview

    This project focuses on predicting gold prices (denoted as GLD) using machine learning techniques. The analysis involves various financial indicators such as stock prices and currency exchange rates to predict the value of gold based on historical data.

    Objectives

    The primary objectives of this notebook are to:

    1. Build a Machine Learning Model: Create a model that can accurately predict GLD prices based on other financial metrics.
    2. Data Insights: Obtain insights from the data using the Pandas library.
    3. Correlation Analysis: Analyze the correlation of other features with the GLD price.
    4. Model Training and Evaluation: Split the data into training and test sets for model training and evaluate its performance.

    About the Data

    Data Overview

    The dataset utilized for this analysis is structured in a Comma-Separated Value (CSV) file format, containing:

    • Rows: 2290
    • Columns: 7
      • Date: Date in MM/DD/YYYY format (object type).
      • SPX: The Standard and Poor’s 500 Index (float).
      • GLD: SPDR Gold Shares ETF price (float).
      • USO: United States Oil Fund price (float).
      • SLV: iShares Silver Trust price (float).
      • EUR/USD: Currency pair value for Euro to USD (float).

    Data Source

    For the data source link, please insert the relevant link here.

    Data Types

    The dataset contains five numerical columns and one date column.

    Import Required Libraries

    To begin working with the data, we first need to import the necessary libraries.

    import pandas as pd                                          # Load data & perform basic operations
    import numpy as np                                           # Numpy for numerical operations
    import matplotlib.pyplot as plt                              # Matplotlib for plotting graphs
    import seaborn as sns                                        # Seaborn for enhanced data visualization
    from sklearn.model_selection import train_test_split         # Split data into training and testing sets
    from sklearn.ensemble import RandomForestRegressor           # Import the Random Forest Regression Model
    from sklearn import metrics                                  # Performance metrics for model evaluation

    Data Collection & Processing

    Loading the Dataset

    We load the gld_price_data.csv file and review the structure of the data.

    # Load the data from CSV file
    gold_data = pd.read_csv("gld_price_data.csv")
    
    # Display the first five and last five rows of the dataset
    print(gold_data.head())
    print(gold_data.tail())

    Understanding the Data

    After loading, we analyze the fundamental aspects of the dataset.

    • Shape of the Dataset: To get the number of rows and columns:
    print(gold_data.shape)  # Output: (2290, 6)
    • Basic Information:
    print(gold_data.info())  # Provides info on data types and non-null counts
    • Missing Values:
    print(gold_data.isnull().sum())  # Check for missing values in each column
    • Statistical Summary:
    print(gold_data.describe())  # Get descriptive statistics

    Data Column Descriptions

    • SPX: Represents the S&P 500 index, which tracks the performance of 500 large companies listed on stock exchanges in the United States.
    • GLD: Represents the price of SPDR Gold Shares, part of the SPDR family of exchange-traded funds (ETFs).
    • USO: Represents the United States Oil Fund LP (USO), which is a traded security for oil investment.
    • SLV: Represents the iShares Silver Trust, an ETF tracking the silver price.
    • EUR/USD: Represents the exchange rate between Euros and U.S. Dollars.

    Correlation Analysis

    We need to understand how GLD prices correlate with other financial variables.

    Calculating Correlation

    To identify relationships, we compute a correlation matrix.

    # Convert the 'Date' column to datetime type for proper analysis
    gold_data['Date'] = pd.to_datetime(gold_data['Date'], errors='coerce')
    
    # Compute the correlation matrix excluding non-numeric columns
    correlation = gold_data.select_dtypes(include=['float64', 'int64']).corr()
    
    # Displaying the correlation matrix
    print("Correlation Matrix:")
    print(correlation)
    
    # Visualizing the correlation using a heatmap
    plt.figure(figsize = (8,8))
    sns.heatmap(correlation, cbar=True, square=True, fmt='.1f',annot=True, annot_kws={'size':8}, cmap='Blues')

    heatmap

    Interpretation of Correlations

    • A positive correlation indicates that as one variable increases, the other tends to increase.
    • A negative correlation indicates that as one variable increases, the other tends to decrease.
    • Zero correlation indicates no relationship between the variables.

    From the correlation matrix output, we observe:

    • GLD (Gold) and SLV (Silver) show a strong correlation (approximately +0.87).
    • GLD has a negligible positive correlation with SPX (about +0.05).
    • GLD has a mild negative correlation with USO (approximately -0.19).

    Data Visualization

    Before training the model, it is useful to visualize the distribution of GLD prices.

    # checking the distribution of the GLD Price using histplot
    sns.histplot(gold_data["GLD"], kde=True, color="Green")
    plt.show()

    histplot

    The visualization indicates that most GLD prices are concentrated around the value of 120, with fewer occurrences at the extremes.

    Feature Selection

    Splitting Features and Target Variable

    Here we set the target variable (Y) as GLD prices and the feature set (X) as the other stock prices excluding GLD and the date.

    # Define features (X) and target variable (Y)
    X = gold_data.drop(["Date", "GLD"], axis=1)  # All columns except 'Date' and 'GLD'
    Y = gold_data["GLD"]  # Target variable GLD
    
    print(X.head())  # Display the features
    print(Y.head())  # Display the target variable

    Train-Test Split

    We split the dataset into training and test sets to evaluate the model’s performance.

    # Dividing the data into training and testing sets (80% - 20% split)
    X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=2)
    
    print(f'Training set size: {X_train.shape[0]}')
    print(f'Test set size: {X_test.shape[0]}')

    Model Training

    Random Forest Regressor

    We utilize the Random Forest Regressor, which is an ensemble method that combines several decision trees to increase the predictive performance.

    # Initializing the Random Forest Regressor
    regressor = RandomForestRegressor(n_estimators=100)
    
    # Training the model with training data
    regressor.fit(X_train, Y_train)

    Model Evaluation

    After training the model, we predict the GLD values using the test data and evaluate the model’s accuracy.

    # Making predictions on the test set
    test_data_prediction = regressor.predict(X_test)
    
    # Evaluating the model using R-squared metric
    error_score = metrics.r2_score(Y_test, test_data_prediction)
    print("R-squared score: ", error_score)

    Visual Comparison of Actual vs. Predicted Values

    We visualize how well the model’s predictions reflect the actual GLD prices.

    # Plotting actual vs predicted values
    plt.plot(Y_test, color='blue', label = 'Actual Value')
    plt.plot(test_data_prediction, color='green', label='Predicted Value')
    plt.title('Actual Price vs Predicted Price')
    plt.xlabel('Number of values')
    plt.ylabel('GLD Price')
    plt.legend()
    plt.show()

    comparison of actual and predicted price

    Conclusion

    The analysis detailed in this notebook demonstrates the application of machine learning to predict gold prices using historical data from various financial indicators. The Random Forest Regressor achieved an R-squared score of approximately 0.989, indicating a high level of predictive accuracy. This suggests that our model is capable of effectively forecasting GLD prices based on the input features.

    Future enhancements could include:

    • Exploring additional features that could improve prediction accuracy.
    • Testing other machine learning algorithms for comparison.
    • Continuously updating the model with new data as it becomes available.
    Visit original content creator repository
  • result-react-002-3-basic-calc

    result-react-002-3-basic-calc

    Small react-app of basic (addition and subtraction) operations of calculating integers

    Getting Started with Create React App

    This project was bootstrapped with
    Create React App.

    Available Scripts

    In the project directory, you can run:

    npm start

    Runs the app in the development mode.
    Open http://localhost:3000 to view it in your browser.

    The page will reload when you make changes.
    You may also see any lint errors in the console.

    npm test

    Launches the test runner in the interactive watch mode.
    See the section about running tests
    for more information.

    npm run build

    Builds the app for production to the build folder.
    It correctly bundles React in production mode and optimizes the build for the best performance.

    The build is minified and the filenames include the hashes.
    Your app is ready to be deployed!

    See the section about
    deployment for more
    information.

    npm run eject

    Note: this is a one-way operation. Once you eject, you can’t go back!

    If you aren’t satisfied with the build tool and configuration choices, you can eject at
    any time. This command will remove the single build dependency from your project.

    Instead, it will copy all the configuration files and the transitive dependencies
    (webpack, Babel, ESLint, etc) right into your project so you have full control over them.
    All of the commands except eject will still work, but they will point to the copied
    scripts so you can tweak them. At this point you’re on your own.

    You don’t have to ever use eject. The curated feature set is suitable for small and
    middle deployments, and you shouldn’t feel obligated to use this feature. However we
    understand that this tool wouldn’t be useful if you couldn’t customize it when you are
    ready for it.

    Learn More

    You can learn more in the
    Create React App documentation.

    To learn React, check out the React documentation.

    Code Splitting

    This section has moved here:
    https://facebook.github.io/create-react-app/docs/code-splitting

    Analyzing the Bundle Size

    This section has moved here:
    https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

    Making a Progressive Web App

    This section has moved here:
    https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

    Advanced Configuration

    This section has moved here:
    https://facebook.github.io/create-react-app/docs/advanced-configuration

    Deployment

    This section has moved here:
    https://facebook.github.io/create-react-app/docs/deployment

    npm run build fails to minify

    This section has moved here:
    https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

    Visit original content creator repository

  • MultipleSavingsAccounts

    MultipleSavingsAccounts

    In this example, you will enhance the Savings Account driver to create multiple accounts. The project will create 3 separate Savings Accounts, simulating 3 different customers creating these accounts. Note that no changes are needed in the Account class โ€“ it describes an account, and it doesnโ€™t matter how many accounts we create with that class. Itโ€™s like a favorite cookie recipe โ€“ itโ€™s the same recipe no matter how many times you bake cookies.

    First, MAKE A COPY of the previous project for the Savings Account.

    In the project in Example 1, a Savings Account was created with this line:
    Account savingsAccount = new Account();

    In this project, for clarity, name that account โ€œsavings1โ€, like this:
    Account savings1 = new Account();

    To create a second account, you repeat that same code but with a different name for the object.
    Account savings1 = new Account(); // first account
    Account savings2 = new Account(); // second account

    When this executes, there will be 2 distinct account objects. Each one has its own instance variables of balance and interest rate, and each has its own methods to get and set its variables and to grow.

    Create a third account.

    The original project asked the user for 3 pieces of information for 1 account. This project simulates asking 3 different users for those 3 pieces of information. That sounds like repetition, so use a FOR loop to ask for the data and assign the values to the variables in each object. Also grow the accounts inside this loop. You must use the same variables for the user input โ€“ balance, interestRate, and cycles โ€“ for each userโ€™s information. Do not create 3 sets of those variables.

    Because you have to refer to each Account object by its specific name, you will see what looks like duplication of code when setting the values for each object.

    Make sure you fully set up all 3 of the objects inside the FOR loop.

    Outside of the FOR loop, display the results for all 3 accounts. Because the number of cycles was not saved in the Account object, the output canโ€™t display that value in the output as was done in the previous version of this project.

    See below for the sample session. Note that you must have the usual heading with your name and a blank line. There must be a blank line between accounts โ€“ remember to use the escape character of โ€œ\nโ€ in the print statements, do NOT use a print statement that only creates a blank line. There must be a blank line before the results are printed. The values of the results must be formatted to display comma separators and only 2 decimal places.

    == We’re Using GitHub Under Protest ==

    This project is currently hosted on GitHub. This is not ideal; GitHub is a
    proprietary, trade-secret system that is not Free and Open Souce Software
    (FOSS). We are deeply concerned about using a proprietary system like GitHub
    to develop our FOSS project. We have an
    open {bug ticket, mailing list thread, etc.} where the
    project contributors are actively discussing how we can move away from GitHub
    in the long term. We urge you to read about the
    Give up GitHub campaign from
    the Software Freedom Conservancy to understand
    some of the reasons why GitHub is not a good place to host FOSS projects.

    If you are a contributor who personally has already quit using GitHub, please
    check this resource for how to send us contributions without
    using GitHub directly.

    Any use of this project’s code by GitHub Copilot, past or present, is done
    without our permission. We do not consent to GitHub’s use of this project’s
    code in Copilot.

    Logo of the GiveUpGitHub campaign

    Visit original content creator repository

  • pki

    Certificate Authority Management Utilities

    This repo contains helpful and easy to use utilities for managing the public key
    infrastructure (PKI) at your organization, or for yourself. You can do a lot
    here:

    • Generate a Root Certificate Authority
    • Create Intermediate CAs, like a TLS, Code-signing, or Email CA
    • Sign and issue web server certificates for your domains
    • Create personal email and browser PKCS-12 certificates for email and
      web-based authentication

    This project heavily utilizes OpenSSL and requires Bash.


    Table of Contents

    1. Introduction
    2. Creating a Root Certificate Authority
      1. Update Config File
      2. Run Utility
    3. Creating Intermediate Certificate Authorities
      1. Run Utilities
    4. Creating a Web SSL Certificate for a Domain
      1. Run Utility
    5. Creating a Client SSL Certificate
      1. Run Utility
      2. Browser Bundle
    6. Final Notes
      1. Security
      2. Web Server Install
      3. Browser Install
      4. Known Issues

    1. Introduction

    All of the utilities are in the bin directory. These files use the config
    files in the etc directory. There’s no reason to ever edit any thing in these
    two folders.

    When you run the tools, they will create the folders ca, certs, and crl.
    These will contain your generated certificates, private keys, certificate
    signing requests, certificate revocation lists, database, and serial files that
    OpenSSL generates.

    2. Creating a Root Certificate Authority

    The first thing you’ll want to do is create the Root CA. This is the master
    certificate and key that will sign all of the Intermediate CAs. Intermediate
    CAs are the TLS CA for signing both web server and web client certificates, the
    Software CA for signing software packages, and the Email CA for signing S/MIME
    certificates.

    Structuring your PKI hierarchy this way allows the Root key to stay private or
    behind multiple layers of security. The Intermediate keys, if ever exposed,
    could be revoked without putting the entire system in jeopardy. This is a best
    practice that we’ll adhere to in these utilities.

    2.1 Update Config File

    Update the config file in this directory to have the correct names and info.
    These names will be embedded into the certificates.

    2.2 Run Utility

    To generate the Root CA:

    $> ./bin/root-ca.sh
    

    This will guide you through the set-up process. It will create the following
    files and folders:

    • /ca Certificate Authority files
      • /root-ca Root CA files, certificates and signing requests
        • /db Root CA database and serial files
        • /private Key files, this is untracked in git
          • RootCA.key Private key file for Root CA
        • RootCA.crt Certificate file
        • RootCA.csr Signing request file
    • /crl Ceritificate revocation lists
      • RootCA.crl Public revocation list file, this should ultimately go on
        your webserver. The URL will be embedded into certificates.

    3. Creating Intermediate Certificate Authorities

    Now that we have the Root CA, we’ll create all of the Intermediate CAs. The only
    required one to finish this guide is the TLS CA but it’s simple to generate them
    all.

    3.1 Run Utilities

    To generate the TLS CA:

    $> ./bin/tls-ca.sh
    

    This will guide you through the set-up process. It will create the following
    files and folders:

    • /ca
      • /tls-ca TLS CA files, certificates and signing requests
        • /db TLS CA database and serial files
        • /private Key files, this is untracked in git
          • TLSCA.key Private key file for Root CA
        • TLSCA.crt Certificate file
        • TLSCA.csr Signing request file
        • TLSCAChain.pem Chained certificate file containing the Root and TLS CA
          certificates.
    • /crl
      • TLSCA.crl Public revocation list file, this should ultimately go on your
        webserver. The URL will be embedded into certificates.

    Similar files are created for the other two Intermediate CAs. To generate the
    Software CA:

    $> ./bin/software-ca.sh
    

    To generate the Email CA:

    $> ./bin/email-ca.sh
    

    4. Creating a Web SSL Certificate for a Domain

    The TLS CA is used to sign web server certificates, which is the most common
    application and use-case for PKI and probably why you’re here ๐Ÿ˜›

    Creating a new server certificate is simple, and you can just follow the
    on-screen instructions. Just make sure to read the few instructions included.
    Please remember these three things:

    1. The fully qualified domain name (FQDN) is usually of the form www.domain.com.
    2. When adding FQDNs at the beginning, add both the www and non-www domains. For
      example, both www.example.org and example.org. The script will prompt you to
      add as many as you’d like. You can probably even do a wildcard but I haven’t
      tested that yet.
    3. When adding the Organization Name during the CSR questions, make sure it’s
      the same “Company Name” you have in your config file. Otherwise, the
      process will halt and you will have to start over! This is an OpenSSL quirk.

    4.1 Run Utility

    To generate a new web server certificate:

    $> ./bin/server.sh
    

    This will create the following files and folders:

    • /certs Server and client files
      • /tls-ca TLS CA signed files
        • /private Key files, this is untracked in git
          • example.org.key Private key file for your web domain. Your web
            server will need this file.
        • example.org.crt Web domain certificate file
        • example.org.csr Signing request file
        • example.org.bundle.pem Certificate bundle containing the server’s
          signed and issued certificate, the Intermediate TLS CA’s certificate,
          and the Root CA’s certificate. Your web server will need this file.

    5. Creating a Client SSL Certificate

    An often unused, but very powerful security mechanism is PKCS-12 client
    certificate authentication. These are certificates issued to people or devices
    that are signed by the Intermediate CA and grant that person or device access to
    the web server. In nginx, this is done by using ssl_client_certificate and
    pointing that config optionto the TLSCAChain.pem file copied to your web
    server.

    This utility will generate a password protected .p12 file that the user can
    import into their web browser. You can then set up your web server to optionally
    require a client certificate for access. This client certificate replaces the
    need for the user to keep a password and provides greater security to any
    application.

    5.1 Run Utility

    To generate a client certificate:

    $> ./bin/client.sh
    

    Here are some helpful notes:

    1. This will prompt you to create a password for the client’s private key. Make
      sure you enter one at least 4 characters long or the script will halt.
    2. During the CSR process, it will ask your for the “Organization Name”. Make
      sure this is the same as the “Company Name” in the config file.
    3. During the CSR process, enter the user’s name into the “Common Name” field,
      and enter their email address into the “Email Address” field.
    4. You will need the TLS CA private key password to sign this client
      certificate.

    The following files are generated:

    • /certs
      • /tls-ca
        • /private
          • stallman_richard.key Private key file for the client.
          • stallman_richard.p12 P12 browser bundle file. This needs to be
            imported into the browser along with the trusted Root CA
            certificate file.
        • stallman_richard.crt Client certificate file
        • stallman_richard.csr Signing request file

    5.2 Browser Bundle

    At the end of the script, you are asked if you want to generate a “client
    certificate bundle”. This is the .p12 file from earlier. If you do this, you
    will be prompted for a name to embed into the file. This name will display to
    the user when they are asked by their browser to select a certificate.

    You do not need to enter an export password but it is strongly recommended that
    you do. The .p12 files should be treated like private keys since they contain
    both the public and private key parts.

    6. Final Notes

    6.1 Security

    Always make sure .key and .p12 files remain untracked. This is automatically
    done for you through .gitignore files but it’s important that you know this.
    These files should also be chmod 400 to protect them on the web server.

    6.2 Web Server Install

    Your web server will want the example.org.key and example.org.bundle.pem
    files for it to load the SSL correctly. If you’re using client certificates,
    also copy over the TLSCAChain.pem file.

    6.3 Browser Install

    Once you create a server certificate, your browser will not immediately trust
    it. To do this automatically for all server certificates that you create, add
    your Root CA certificate file to your browser’s list of trusted authorities.
    This is the file RootCA.crt (or similarly named) in the ca folder.

    If you’re on MacOS, double click this file and make sure you open it again in
    KeyChain, expand the Trust tab, and ensure that everything is always trusted.

    For Chrome, go to Settings -> Show Advanced Settings -> Manage Certificates.
    This will prompt KeyChain in MacOS or show you a window with an Authorites tab.
    If you see the Chrome Certificates window, then go to the Authorities tab and
    click “Import” and select the Root CA certificate file. Make sure you trust this
    authority.

    For Firefox, go to Preferences -> Advanced -> Certificates and click “View
    Certificates”. Click the Authorities tab and then click “Import” and select the
    Root CA certificate file. Make sure you trust this authority.

    You may need to restart your browser for this to take effect, since SSL is often
    cached.

    6.4 Known Issues

    Here is a list of the current limitations and planned updates:

    1. There’s no way to revoke certificates really. This is needed to be added as
      as a command in some of the scripts.
    2. CRLs would then need to be inspected to see if they’re working with the
      revokations. CRLs are also difficult to get onto a public web server. This
      problem, if solved, should be documented here.

    At this point, it’s still somewhat unclear to me what the databases and serial
    files are that get generated. I think I need to spend more time with revokations
    to understand that.

    Visit original content creator repository

  • NFE1_2_3_TurtleNeck

    Turtleneck Blog Project

    ํ”„๋กœ์ ํŠธ ์†Œ๊ฐœ

    Turtleneck Blog๋Š” ๊ฐœ๋ฐœ์ž๋“ค์„ ์œ„ํ•œ ํ…Œํฌ ๋ธ”๋กœ๊ทธ ํ”Œ๋žซํผ์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๋Š” ๋งˆํฌ๋‹ค์šด ์—๋””ํ„ฐ๋ฅผ ํ†ตํ•ด ์‰ฝ๊ฒŒ ๊ธ€์„ ์ž‘์„ฑํ•˜๊ณ , ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๋“ค๊ณผ ์ข‹์•„์š” ๋ฐ ๋Œ“๊ธ€์„ ํ†ตํ•ด ํ”ผ๋“œ๋ฐฑ๊ณผ ์†Œํ†ตํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ํ”Œ๋žซํผ์€ ์ „๋ฌธ์ ์ธ ๊ธฐ์ˆ  ํฌ์ŠคํŠธ๋ฅผ ์‰ฝ๊ฒŒ ๊ณต์œ ํ•˜๊ณ , ์ฝ”๋“œ ๋ฐ ๊ธฐ์ˆ ์— ๋Œ€ํ•ด ๋…ผ์˜ํ•  ์ˆ˜ ์žˆ๋Š” ๊ณต๊ฐ„์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋ธ”๋กœ๊ทธ๋Š” ๋‹จ์ˆœํ•œ ์ •๋ณด ๊ณต์œ ๋ฅผ ๋„˜์–ด์„œ, ๊ฐœ๋ฐœ์ž ๊ฐ„์˜ ์†Œํ†ต๊ณผ ํ”ผ๋“œ๋ฐฑ์„ ํ†ตํ•ด ์„œ๋กœ์˜ ์„ฑ์žฅ์„ ๋„์šธ ์ˆ˜ ์žˆ๋Š” ์ปค๋ฎค๋‹ˆํ‹ฐ๋ฅผ ์ง€ํ–ฅํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๋Š” ํฌ์ŠคํŠธ๋ฅผ ์ž‘์„ฑํ•˜๊ณ , ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ›์Œ์œผ๋กœ์จ ์ž์‹ ์˜ ๊ธฐ์ˆ ์  ์—ญ๋Ÿ‰์„ ํ‚ค์šฐ๊ณ  ๋” ๋‚˜์€ ๊ธ€์„ ์ž‘์„ฑํ•˜๋Š” ๊ธฐํšŒ๋ฅผ ์–ป๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

    ์ฃผ์š” ๊ธฐ๋Šฅ

    • ๋งˆํฌ๋‹ค์šด์„ ํ†ตํ•œ ๊ฐ„ํŽธํ•œ ๊ธ€ ์ž‘์„ฑ: react-markdown-editor-lite์™€ markdown-it์„ ์‚ฌ์šฉํ•ด ์‰ฝ๊ฒŒ ํฌ์ŠคํŠธ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋งˆํฌ๋‹ค์šด์„ ์ด์šฉํ•˜๋ฉด ์ฝ”๋“œ ๋ธ”๋ก, ํ‘œ, ๋ฆฌ์ŠคํŠธ ๋“ฑ ๋‹ค์–‘ํ•œ ํ˜•์‹์„ ๊ฐ„ํŽธํ•˜๊ฒŒ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ง๊ด€์ ์ธ ํŽธ์ง‘ ๊ฒฝํ—˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
    • ์ข‹์•„์š” ๋ฐ ๋Œ“๊ธ€ ๊ธฐ๋Šฅ: ๊ฐ ๊ฒŒ์‹œ๋ฌผ์— ๋Œ€ํ•ด ์ข‹์•„์š”์™€ ๋Œ“๊ธ€์„ ๋‚จ๊ธธ ์ˆ˜ ์žˆ์–ด, ์‚ฌ์šฉ์ž ๊ฐ„์˜ ํ™œ๋ฐœํ•œ ์†Œํ†ต์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ์ž‘์„ฑ์ž๋Š” ์ž์‹ ์˜ ํฌ์ŠคํŠธ์— ๋Œ€ํ•œ ํ”ผ๋“œ๋ฐฑ์„ ์ง์ ‘ ํ™•์ธํ•˜๊ณ , ์ด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ๊ธ€์˜ ํ’ˆ์งˆ์„ ๋†’์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • ๊ด€๋ฆฌ์ž ๊ธฐ๋Šฅ: ์นดํ…Œ๊ณ ๋ฆฌ ๊ด€๋ฆฌ, ๋Œ“๊ธ€ ๊ด€๋ฆฌ, ๋ธ”๋กœ๊ทธ ์ •๋ณด ๊ด€๋ฆฌ ๊ธฐ๋Šฅ์„ ํ†ตํ•ด ๋ธ”๋กœ๊ทธ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ด€๋ฆฌ์ž๋Š” ์‚ฌ์šฉ์ž ํ™œ๋™์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ , ์›ํ™œํ•œ ๋ธ”๋กœ๊ทธ ์šด์˜์„ ์œ„ํ•ด ์ฝ˜ํ…์ธ ๋ฅผ ์œ ์ง€ํ•˜๊ณ  ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ๊ธฐ์ˆ  ์Šคํƒ

    • ํ”„๋ก ํŠธ์—”๋“œ: React, Sass, react-markdown-editor-lite, markdown-it์„ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์šฉ์ž ์นœํ™”์ ์ธ ์ธํ„ฐํŽ˜์ด์Šค์™€ ์Šคํƒ€์ผ์„ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ฐ˜์‘ํ˜• ๋””์ž์ธ์„ ์ ์šฉํ•˜์—ฌ ๋‹ค์–‘ํ•œ ๊ธฐ๊ธฐ์—์„œ ์ตœ์ ์˜ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
    • ๋ฐฑ์—”๋“œ: Next.js, NextAuth(JWT ์‚ฌ์šฉ), Mongoose, Bcrypt๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ ๊ด€๋ฆฌ์™€ ์ธ์ฆ ๊ธฐ๋Šฅ์„ ๊ฐ•ํ™”ํ–ˆ์Šต๋‹ˆ๋‹ค. ํšจ์œจ์ ์ธ ์„œ๋ฒ„ ์‚ฌ์ด๋“œ ๋ Œ๋”๋ง์„ ํ†ตํ•ด ์„ฑ๋Šฅ์„ ์ตœ์ ํ™”ํ•˜๊ณ , JWT๋ฅผ ์‚ฌ์šฉํ•œ ๋ณด์•ˆ ๊ฐ•ํ™”๋ฅผ ๋„๋ชจํ–ˆ์Šต๋‹ˆ๋‹ค.
    • ๋ณด์•ˆ: ์ธ์ฆ ๋ฐ ๋ณด์•ˆ ๊ฐ•ํ™”๋ฅผ ์œ„ํ•ด next-auth์™€ Bcrypt๋ฅผ ์‚ฌ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ์•ˆ์ „ํ•˜๊ฒŒ ํ•ด์‹ฑ๋˜์–ด ์ €์žฅ๋˜๋ฉฐ, ์‚ฌ์šฉ์ž ๋ฐ์ดํ„ฐ๋Š” ๋ณดํ˜ธ๋ฉ๋‹ˆ๋‹ค.
    • ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค: MongoDB, Mongoose๋ฅผ ์‚ฌ์šฉํ•œ DB ์—ฐ๊ฒฐ ๋ฐ ์„ค์ •์„ ํ†ตํ•ด ํ™•์žฅ์„ฑ ๋†’์€ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋Š” ๊ฒŒ์‹œ๊ธ€, ์‚ฌ์šฉ์ž, ๋Œ“๊ธ€ ๋“ฑ์„ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

    ํด๋” ๊ตฌ์กฐ

    NFE1_2_3_TurtleNeck/
    โ”œโ”€โ”€ client/
    โ”‚   โ”œโ”€โ”€ public/
    โ”‚   โ”‚   โ”œโ”€โ”€ images/
    โ”‚   โ”œโ”€โ”€ src/
    โ”‚   โ”‚   โ”œโ”€โ”€ app/
    โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ admin/
    โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ api/
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ auth/
    โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ [...nextauth]/route.js
    โ”‚   โ”‚   โ”œโ”€โ”€ components/
    โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Footer/
    โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Navigation/
    โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PostCard/
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ MainPostCard/
    โ”‚   โ”‚   โ”œโ”€โ”€ utils/
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ api.js
    โ””โ”€โ”€ server/
        โ”œโ”€โ”€ app/
        โ”‚   โ”œโ”€โ”€ api/
        โ”‚   โ”‚   โ”œโ”€โ”€ admin/
        โ”‚   โ”‚   โ”œโ”€โ”€ auth/
        โ”‚   โ”‚   โ”œโ”€โ”€ category/
        โ”‚   โ”‚   โ”œโ”€โ”€ comment/
        โ”‚   โ”‚   โ”œโ”€โ”€ like/
        โ”‚   โ”‚   โ”œโ”€โ”€ post/
        โ”‚   โ”‚   โ””โ”€โ”€ upload/
        โ”‚   โ””โ”€โ”€ db/
        โ”‚       โ”œโ”€โ”€ models/
        โ”‚       โ””โ”€โ”€ dbConnect.js   
        โ””โ”€โ”€ public/
            โ””โ”€โ”€ uploads/
    

    ์œ„์™€ ๊ฐ™์€ ํด๋” ๊ตฌ์กฐ๋ฅผ ํ†ตํ•ด ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ฒ„ ์ฝ”๋“œ๊ฐ€ ๋ช…ํ™•ํ•˜๊ฒŒ ๋ถ„๋ฆฌ๋˜์–ด ์žˆ์œผ๋ฉฐ, ์œ ์ง€ ๋ณด์ˆ˜์™€ ๊ธฐ๋Šฅ ํ™•์žฅ์ด ์šฉ์ดํ•˜๋„๋ก ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๊ฐ ํด๋”๋Š” ์—ญํ• ์— ๋”ฐ๋ผ ์„ธ๋ถ„ํ™”๋˜์–ด ์žˆ์œผ๋ฉฐ, ํŒŒ์ผ ๊ฒฝ๋กœ๋ฅผ ์ง๊ด€์ ์œผ๋กœ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ํ”„๋กœ์ ํŠธ ์ง„ํ–‰ ๊ณผ์ •

    1. ๊ธฐํš/์„ค๊ณ„ (10/14 – 10/23): ์ฃผ์ œ ์„ ์ •, ์š”๊ตฌ์‚ฌํ•ญ ์ •์˜์„œ ์ž‘์„ฑ, ํ”„๋กœ์ ํŠธ ๊ตฌ์„ฑ๋„, ํด๋ž˜์Šค ๋ฐ ์‹œํ€€์Šค ๋‹ค์ด์–ด๊ทธ๋žจ ์ž‘์„ฑ. ์ด ๋‹จ๊ณ„์—์„œ๋Š” ์‚ฌ์šฉ์ž์˜ ์š”๊ตฌ๋ฅผ ์ •ํ™•ํžˆ ๋ถ„์„ํ•˜๊ณ , ์ด๋ฅผ ํ† ๋Œ€๋กœ ํ”„๋กœ์ ํŠธ์˜ ์ „๋ฐ˜์ ์ธ ๊ตฌ์กฐ๋ฅผ ์„ค๊ณ„ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ชจ๋“  ํŒ€์›์ด ํ”„๋กœ์ ํŠธ์˜ ๋ชฉํ‘œ์™€ ์—ญํ• ์„ ๋ช…ํ™•ํžˆ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋„๋ก ๋‹ค์–‘ํ•œ ๋„๊ตฌ๋ฅผ ํ™œ์šฉํ•ด ๋ฌธ์„œ๋ฅผ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.
    2. ๊ฐœ๋ฐœ/๋ณ‘ํ•ฉ (10/23 – 11/05): ๊ณตํ†ต ์ปดํฌ๋„ŒํŠธ ๊ตฌํ˜„, ํŽ˜์ด์ง€ ํ™”๋ฉด ๊ตฌํ˜„, ์ธ์ฆ, ์ธ๊ฐ€, ๋ณด์•ˆ ์ฒ˜๋ฆฌ ๋ฐ DB ์„ค์ •์„ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ฐ ํŒ€์›์ด ๋งก์€ ์—ญํ• ์— ๋”ฐ๋ผ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๊ณ , ์ด๋ฅผ ๋ณ‘ํ•ฉํ•˜์—ฌ ์ „์ฒด์ ์ธ ์‹œ์Šคํ…œ์˜ ๋™์ž‘์„ ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ฒ„๊ทธ ์ˆ˜์ • ๋ฐ ์ฝ”๋“œ ๋ฆฌ๋ทฐ๋ฅผ ํ†ตํ•ด ํ’ˆ์งˆ์„ ๋†’์˜€์Šต๋‹ˆ๋‹ค.
    3. ์ข…๋ฃŒ/๋ฐœํ‘œ (11/05 – 11/06): ์ตœ์ข… ์ฝ”๋“œ ๋ณ‘ํ•ฉ ๋ฐ ๋ฐœํ‘œ ์ค€๋น„. ํ”„๋กœ์ ํŠธ์˜ ๋งˆ์ง€๋ง‰ ๋‹จ๊ณ„๋กœ, ์ตœ์ข…์ ์ธ ๋ฒ„๊ทธ๋ฅผ ์ˆ˜์ •ํ•˜๊ณ  ์•ˆ์ •์„ฑ์„ ํ™•๋ณดํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ฐœํ‘œ ์ž๋ฃŒ๋ฅผ ์ค€๋น„ํ•˜์—ฌ ํ”„๋กœ์ ํŠธ์˜ ๊ฒฐ๊ณผ๋ฌผ๊ณผ ๊ณผ์ •์„ ๊ณต์œ ํ–ˆ์Šต๋‹ˆ๋‹ค.

    ํŒ€ ๊ตฌ์„ฑ

    • ํ”„๋ก ํŠธ์—”๋“œ: ์ด๋™์ธ, ๊น€ํ˜œ์ค€
      • ์ƒ์„ธํŽ˜์ด์ง€, ์นด๋“œ ์ปดํฌ๋„ŒํŠธ, ๋ฉ”์ธํŽ˜์ด์ง€, ๊ด€๋ฆฌ์ž CSS ๊ตฌํ˜„
      • ์‚ฌ์šฉ์ž์˜ ์š”๊ตฌ์— ๋งž๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌ์ถ•ํ•˜๊ณ , CSS๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์„ ๊ฐœ์„ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
    • ๋ฐฑ์—”๋“œ: ์ •ํ•ด๋Ÿ‰, ์ตœ์ˆ˜์ง„
      • ๋ณด์•ˆ ์„ค์ •, ํด๋ผ์ด์–ธํŠธ API, ์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์„ค์ •
      • ๋ฐ์ดํ„ฐ์˜ ์•ˆ์ „ํ•œ ์ €์žฅ๊ณผ ํšจ์œจ์ ์ธ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•ด ๋‹ค์–‘ํ•œ ๋ฐฑ์—”๋“œ ๊ธฐ์ˆ ์„ ํ™œ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.

    ํŽ˜์ด์ง€ ๊ตฌ์„ฑ

    • ๋ฉ”์ธ ํŽ˜์ด์ง€: ๋„ค๋น„๊ฒŒ์ด์…˜, ๋ธ”๋กœ๊ทธ ์ด๋ฆ„ & ์„ค๋ช…, ์ตœ์‹  ๊ฒŒ์‹œ๊ธ€, ๊ฒŒ์‹œ๊ธ€ ์นด๋“œ ๋ชฉ๋ก, ํŽ˜์ด์ง€๋„ค์ด์…˜, ํ‘ธํ„ฐ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฉ”์ธ ํŽ˜์ด์ง€๋Š” ๋ธ”๋กœ๊ทธ์˜ ์ฒซ ์ธ์ƒ์„ ๊ฒฐ์ •์ง“๋Š” ์ค‘์š”ํ•œ ์š”์†Œ๋กœ, ์‚ฌ์šฉ์ž ์นœํ™”์ ์ธ ๋””์ž์ธ๊ณผ ์ตœ์‹  ์ •๋ณด ์ œ๊ณต์„ ๋ชฉํ‘œ๋กœ ํ–ˆ์Šต๋‹ˆ๋‹ค.
    • ์ƒ์„ธ ํŽ˜์ด์ง€: ๊ฒŒ์‹œ๊ธ€ ์ œ๋ชฉ, ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ, ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ ๋‚ด์šฉ, ๋Œ“๊ธ€ ๊ธฐ๋Šฅ์„ ํฌํ•จํ•˜์—ฌ ์‚ฌ์šฉ์ž๊ฐ€ ํฌ์ŠคํŠธ๋ฅผ ๊นŠ์ด ์žˆ๊ฒŒ ์ดํ•ดํ•˜๊ณ  ์†Œํ†ตํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋Œ“๊ธ€ ๊ธฐ๋Šฅ์„ ํ†ตํ•ด ์‚ฌ์šฉ์ž๋Š” ์ง์ ‘์ ์ธ ์˜๊ฒฌ์„ ๋‚จ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • ๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑ/์ˆ˜์ • ํŽ˜์ด์ง€: ์นดํ…Œ๊ณ ๋ฆฌ, ์ œ๋ชฉ, ํƒœ๊ทธ, ์ธ๋„ค์ผ ์ž…๋ ฅ ๋ฐ ๋งˆํฌ๋‹ค์šด ์—๋””ํ„ฐ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜์—ฌ, ์‚ฌ์šฉ์ž๊ฐ€ ์†์‰ฝ๊ฒŒ ๊ฒŒ์‹œ๊ธ€์„ ์ž‘์„ฑํ•˜๊ณ  ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋•์Šต๋‹ˆ๋‹ค. ๋ฏธ๋ฆฌ๋ณด๊ธฐ ๊ธฐ๋Šฅ์„ ํ†ตํ•ด ์ž‘์„ฑ ์ค‘์ธ ๊ธ€์˜ ํ˜•ํƒœ๋ฅผ ์ฆ‰์‹œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • ๊ด€๋ฆฌ ํŽ˜์ด์ง€: ๋ธ”๋กœ๊ทธ ์ •๋ณด ๊ด€๋ฆฌ, ์นดํ…Œ๊ณ ๋ฆฌ ๊ด€๋ฆฌ, ๋Œ“๊ธ€ ๊ด€๋ฆฌ ๊ธฐ๋Šฅ์ด ์žˆ์œผ๋ฉฐ, ๊ด€๋ฆฌ์ž๋Š” ์ด๋ฅผ ํ†ตํ•ด ๋ธ”๋กœ๊ทธ์˜ ์ฝ˜ํ…์ธ ์™€ ์‚ฌ์šฉ์ž ํ™œ๋™์„ ์ฒด๊ณ„์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ์„ค์น˜ ๋ฐ ์‹คํ–‰ ๋ฐฉ๋ฒ•

    1. ์ €์žฅ์†Œ๋ฅผ ํด๋ก ํ•ฉ๋‹ˆ๋‹ค.
      git clone [์ €์žฅ์†Œ URL]
    2. ํด๋ผ์ด์–ธํŠธ ๋ฐ ์„œ๋ฒ„ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•˜์—ฌ ํ•„์š”ํ•œ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

      cd client && npm install
      cd ../server && npm install
    3. ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ํŒŒ์ผ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค (.env.local ํŒŒ์ผ).
    4. ๊ฐœ๋ฐœ ์„œ๋ฒ„๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
      npm run dev
    5. ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ์—ฐ๊ฒฐ๋˜๋ฉด, ๋กœ์ปฌ ํ™˜๊ฒฝ์—์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ํ…Œ์ŠคํŠธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ ๊ธฐ๋Šฅ์ด ์˜๋„ํ•œ ๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ณ , ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ๊ฒฝ์šฐ ๋””๋ฒ„๊น…์„ ํ†ตํ•ด ํ•ด๊ฒฐํ•ฉ๋‹ˆ๋‹ค.

    ๋ผ์ด์„ ์Šค

    MIT License๋ฅผ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค. ๋ˆ„๊ตฌ๋‚˜ ์ž์œ ๋กญ๊ฒŒ ์ด ํ”„๋กœ์ ํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ด์— ๋Œ€ํ•œ ์ œ์•ฝ ์‚ฌํ•ญ์€ MIT ๋ผ์ด์„ ์Šค์— ๋ช…์‹œ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

    ๊ธฐ์—ฌ ๋ฐฉ๋ฒ•

    ๊ธฐ์—ฌ๋ฅผ ์›ํ•˜์‹œ๋Š” ๋ถ„์€ ์ด์Šˆ๋ฅผ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ์ œ์ถœํ•ด ์ฃผ์„ธ์š”. ํ•ญ์ƒ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค! ํ”„๋กœ์ ํŠธ์— ๊ธฐ์—ฌํ•จ์œผ๋กœ์จ ๋” ๋‚˜์€ ํ”Œ๋žซํผ์„ ํ•จ๊ป˜ ๋งŒ๋“ค์–ด ๋‚˜๊ฐˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฒ„๊ทธ ์‹ ๊ณ , ๊ธฐ๋Šฅ ์ œ์•ˆ, ์ฝ”๋“œ ๊ฐœ์„  ๋“ฑ ๋‹ค์–‘ํ•œ ํ˜•ํƒœ์˜ ๊ธฐ์—ฌ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

    Visit original content creator repository

  • arithmo

    Arithmo

    A fast and simple-to-use library for math expressions processing

    Version: v1.0.0 License: GPL v3

    Contents

    Usage

    Here is an example of usage (for the full version see example/main.c file):

    const char* expression = "(23 - 4) * 3";
    
    // Creating an new arithmo instance:
    artm_calc_t* calc = artm_calc_init(5); // 5 is the approximate number of variables that will be used
    
    // Processing a mathematical expression:
    artm_result_t result = artm_calc_eval(calc, expression);
    
    // Saving the token to see exactly where the error is in the expression:
    const artm_token_t* token = &result.as.token;
    
    switch (result.status) {
      case ARTM_NULL_CALC:
        return printf("[ERROR] NULL_CALC\n");
      case ARTM_NULL_EXPR:
        return printf("[ERROR] NULL_EXPR\n");
      case ARTM_ALLOC_ERR:
        return printf("[ERROR] ALLOC_ERR\n");
      case ARTM_INV_TOKEN:
        return printf("[ERROR] INV_TOKEN -> '%.*s'\n", (int) token->size, token.target);
      case ARTM_UNDEF_VAR:
        return printf("[ERROR] UNDEF_VAR -> '%.*s'\n", (int) token->size, token.target);
      case ARTM_SUCCESS:
        return printf("[SUCCESS] %s = %g\n", expression, result.as.value);
    }
    
    // Destroying the instance:
    artm_calc_free(calc);

    After project building you can run this example as you can see here.

    Also, you can see xcalc – an real example of using Arithmo.

    Building and Installation

    Dependencies

    • C compiler (gcc, clang, etc…)
    • cmake (>= 3.17)

    These packages can usually be installed through your distributions package manager.

    Building the project

    To build the project, we first need to create a separate build directory:

    mkdir build
    

    Now that we’ve created our build directory (assuming it’s created in the project root), we can cd into it and run cmake and pass the parent directory path to it, which is where the CMakeLists.txt file is located:

    cd build
    cmake ..
    

    Once cmake is done generating makefiles, we can build the library by running make inside our build directory:

    make
    

    Running example

    ./example
    

    Installing

    To install the library run:

    sudo make install
    

    By default, the libraries and headers will be installed in /usr/local/lib and /usr/local/include directories.

    License

    Arithmo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. For more details, see LICENSE file.

    Contributing

    Contributions are welcome. If you have a feature request, or have found a bug, feel free to open a new issue. If you wish to contribute code, see CONTRIBUTING.md for more details.

    Visit original content creator repository