Coder Social home page Coder Social logo

athul / jimbru Goto Github PK

View Code? Open in Web Editor NEW
44.0 3.0 5.0 67 KB

A lightweight analytics server with FastAPI and deta.sh Base as DB. A glorified hit-counter of sorts 😁

License: MIT License

HTML 48.11% Python 48.44% JavaScript 3.45%
python analytics deta fastapi nosql

jimbru's Introduction

IMPORTANT: There seems to be an error in deploying this, planning for a rewrite of the whole.

Jimbru

Jimbru is an Privacy Oriented web analytics Server which is built with FastAPI and Deta Base as DB.

Jimbru is heavily inspired by Shynet which is also an Analytics server built with Django.

Not for Production Level use. It's hacky to the core. I made it for a Personal Use and doesn't have any fancy features.

Features

  • Lightweight
  • Privacy Oriented
  • Easily Deployable (on deta.sh)
  • 6 lines of JS code gets the current URL, referrer and load time.
  • Charts with Frappe Charts πŸ“Š
  • Jinja2 Templating and Tailwind CSS for Frontend
  • Cookie based Authentication
  • User OS and device from user-agent header
  • user location and network from user ip header

Not Included Features

  • Caching
  • Bounce rate
  • Session Time
  • Unique Hits

Demo

Demo Gif

Deploying

Before deploying you need to get some Credentials

Prep Work

  • Signup for an account in https://deta.sh

  • Create a new Project

  • Get the Project Key and save it in the .env file as below

  • Install the Deta cli. This is for deploying to Deta.

  • Create a .env file inside the app/routes directory with the following keys

    TITLE=<title of the site>
    DOMAIN=<domain of the deployed server>
    PKEY=<Deta Project Key>
    PNAME=<Deta Base DB Name>
    SECRET_JWT=<Secret for JWT. Get than with→ import os; print(os.urandom(24).hex())>
    USERNAME=<username for authenticating>
    PASSWORD=<password for authenticating>

The PNAME can be anything.


  1. Fork/Clone this Repository
  2. You can run the code locally by installing the dependencies inside the app directory and running uvicorn main:app --reload inside the app directory.
  3. Inside the app directory you can create a new Micro with $ deta new. This will create a new Micro. You will get the domian from the output of the command. Save that domain in the DOMAIN key in the .env file, without a trailing /.
  4. Run $ deta update -e routes/.env to update the environment variables in the micro.
  5. Run $ deta deploy inside the app directory and the code will be deployed.
  6. Profit

Usage

Add a <script> tag for the site

<script src="https://<DOMAIN>/a.js" type="text/javascript"></script>

TODO

  • Caching
  • Better Auth
  • Session Time

LICENSE

MIT

Contributors

jimbru's People

Contributors

athul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jimbru's Issues

Error while running the analyzer.

Hi, I got this error after following all the steps in the instructions:

  File "/var/task/main.py", line 3, in <module>
    from routes import analytics,templates,auth
  File "/var/task/routes/templates.py", line 7, in <module>
    from .auth import manager
  File "/var/task/routes/auth.py", line 10, in <module>
    manager = LoginManager(SECRET,tokenUrl="/auth/login",use_cookie=True)
TypeError: __init__() got an unexpected keyword argument 'tokenUrl'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/python/detalib/debugger.py", line 142, in wrap
    result = func(event, context)
  File "/var/task/_entry.py", line 12, in handler
    import main  # noqa
  File "/var/task/main.py", line 5, in <module>
    from .routes import analytics,templates,auth
ImportError: attempted relative import with no known parent package

Please help with the issue.
Thanks.

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.