Coder Social home page Coder Social logo

noo-analytics's Introduction

noo-analytics

Simple backend service for personal websites

Install

First of all, download and install Go. 1.14 or higher is required.

When installation is done clone the repo with command:

git clone https://github.com/nozgurozturk/noo-analytics

After that install missing dependencies with command:

go mod tidy

Run the app

go run ./cmd/server

Database Support

noo-analytics works with MongoDB and Redis

Environment Variables

MongoDB Variables:

MONGO_DB_USERNAME = 
MONGO_DB_PASSWORD = 
MONGO_DB_HOST = 
MONGO_DB_PORT = 
MONGO_DB_NAME = 
MONGO_DB_QUERY = 

Redis Variables:

REDIS_DB_ADDRESS = 
REDIS_DB_USERNAME =
REDIS_DB_PASSWORD =

Server Variables:

PORT = 
ACCESS_SECRET = 
REFRESH_SECRET = 
# Hour
ACCESS_EXPIRE =
# Minute
REFRESH_EXPIRE = 
ADMIN_MAIL = 

API Documentation

Send User Trace

Request

POST /trace

{
  "ip": "192.168.0.1",
  "loc": "TUR",
  "a": "Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0",
  "act": 1,
  "tag": "home"
}   

Response

    {}

Find Action by Date

Request

  • year, month, day and hour are objects are optional
  • range and its properties are optional

POST /analytics/action/date

{
    "action": 1,
    "year":{
        "isInclude": true,
        "range": {
          "from": 2018,
          "to": 2020
        }
    },
    "month":{
        "isInclude": true,
        "range": {
          "from": 2018,
          "to": 2020
        }
    },
    "day":{
        "isInclude": true,
        "range": {
          "from": 2018,
          "to": 2020
        }
    },
    "hour":{
        "isInclude": true,
        "range": {
          "from": 2018,
          "to": 2020
        }
    }
}

Response

y: year | m: month | d: day | h: hour | v: visitors' ip | uv: unique visitors' ip

[
    {
        "y": 2020,
        "m": 11,
        "d": 6,
        "h": 0,
        "v": [
            "192.168.0.1"
        ],
        "uv": [
            "192.168.0.1"
        ]
    },
    {
        "y": 2020,
        "m": 10,
        "d": 6,
        "h": 0,
        "v": [
            "192.168.0.1"
        ],
        "uv": [
            "192.168.0.1"
        ]
    },
    {
        "y": 2020,
        "m": 10,
        "d": 4,
        "h": 0,
        "v": [
            "192.168.0.1",
            "192.168.0.2",
            "192.168.0.1"
        ],
        "uv": [
            "192.168.0.1",
            "192.168.0.2"
        ]
    }
]

Login

Request

POST /auth/login

{
  "email": "[email protected]",
  "password": "sample_password"
}   

Response

{
    "name": "Sample Name",
    "email": "[email protected]"
} 

Sign Up

Request

POST /auth/signup

{
  "name": "Sample Name",
  "email": "[email protected]",
  "password": "sample_password"
}   

Response

{
    "name": "Sample Name",
    "email": "[email protected]"
} 

Error

Response

{
    "message": "Not Accessible",
    "error": "unauthorized",
    "status": 401
}

noo-analytics's People

Contributors

nozgurozturk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.