How to create user profiles with Bottle and MongoDB? - mongodb

I want to set up user profiles in a Python app that is using Bottle and MongoDB.
I've searched for:
create users profile in bottle python
But the majority of links relate to Flask.
I'm new to Bottle and need a 'from the ground up' introduction to the particular topic of user profiles in Bottle.
I understand that routes are used to trigger functions, and have got several of these routes and functions working.
I'd appreciate it if anyone could provide a newbie friendly guide to understanding and implementing user profiles within the Bottle framework in a MongoDB environment.

There are a couple of authentication mechanisms for Bottle that I've seen. You could attempt to use those user accounts as a starting point to build out a more robust profile.
Cork (authentication): http://cork.firelet.net/
Bottle example user accounts: https://github.com/uvtc/bottle-example-user-accounts
This one might get you closer to what you need but will still require some work to integrate with MongoDB.

Related

How do I create a charge on a Stripe customer from a connected account

I'm creating a type of ride-sharing application for iOS using Swift and Firebase Functions and would like to implement the following workflow:
Passenger requests ride from specific driver
Driver has 2 options
a. Driver accepts and the passengers card is charged
b. Driver declines and thats it
I've gone through pages and pages of Stripes documentation and Github to find the best example to go off, but can't seem to find one that fits what I'm after.
You can find an example here: https://stripe.com/docs/connect/collect-then-transfer-guide
There's also https://rocketrides.io/ which is a complete example, including code, of a ride sharing app.

Emulating tenants using roles

We are developing a keycloak(5.0.0) based solution where our clients can create their account with us and manage their own users - and only their users.
Initially with thought that we could use realms for this. Every client gets their own realm. After initial testing we deemed it might not be a good solution as after creating ~500 realms the application becomes unresponsive(https://issues.jboss.org/browse/KEYCLOAK-4593).
We decided to try using Groups to emulate a tenant. Our objective is to create during an external process(keycloak REST API) a group with an admin user.
Can't find currently a way how to restrict this administrator to be able to only manage their own group(creating subgroups, managing users, and giving them roles).
I've noticed several emails mentioning these features but I fail to find actual examples to make this work.
http://lists.jboss.org/pipermail/keycloak-user/2017-June/010882.html
http://lists.jboss.org/pipermail/keycloak-dev/2017-June/009496.html
The second link shows exactly what we would like to achieve.
Current alternative I can see is to implement a facade(client or separate web app) which would restrict visibility and access to other groups.
Are there other alternatives?

Suggestions on Framework/API to create social graph and cross reference relationships

Short Question Description
I have to develop an application for a security company that will store cases of harassment to their clients and cross reference any case with other cases if it detects it is the same person that is attacking them.
These relationships will be used to create a social graph of criminals and victims.
Initially I thought about managing it as a Social Network with some CMS or maybe Elastic Search with some frontend JS Framework but I have only experience with PHP and some basic React/Node.js so I wonder if there is something better that let me make the queries live as users fill in the forms.
Long Question with Use Case Example
Lets say they have two clients: ProtectedPerson1 and ProtectedPerson2
and there is a case saying BadGuy1 threatened PP1 in twitter with the handle #badguy1.
Then another agent that does not know anything about this case enters a new case for PP2, because someone in facebook is posting private photos of the client.
If they start to put the social information and they type #badguy1 or faceboo.com/badguy1 or anything similar the system should ask "is this the same person?" and if the agent selects Yes then both records of two separate cases are related to the same "criminal".
In the end the final objective is to gather all precedents possible to take legal action against someone if is necessary.
Is there any existing Framework, CMS or API that I can use to manage this relationships and create the desired suggestions and graphs?
After further investigation I found that what I really need is a graph database and the one that stands out as the most used one and with better support and integrations is Neo4j (https://neo4j.com) with a front end in React possibly as they offer official driver for javascript.

What are some patters for designing REST API for user-based platform in AWS?

I am trying to shift towards serverless architecture when it comes to building REST API. I came from Ruby on Rails background.
I have successfully understood and adapted services such as Api Gateway, Cognito, RDS and Lambda functions, however I am struggling with putting it all together in optimal way.
My case is the following. I have a simple user based platform when there are multiple resources related to application members say blog application.
I have used Cognito for the sake of authentication and Aurora as the database service for keeping thing like articles and likes..
Since the database and Cognito user pool are decoupled, it is hard for me to do things like:
Fetching users that liked particular article
Fetching users comments
It seems problematic for me because I need to pass some unique Cognito user identifier (retrieved during authorization phase in API gateway) to lambda function which will then save the database record with an external reference to this user. On the other hand, If I were to fetch particular users, firstly I must fetch their identifiers from my relation database and then request users details from Cognito user pool..I lack some standard ways of accessing current user in my lambda functions as well as mechanisms for easily associating databse record with that user..
I have not found some convincing recommended patterns for designing such applications even though it seems like a very common problem and I am having hard time struggling if my approach is correct..
I would appreciate some comments on what are some patterns to consider when designing simple user based platform and what are the pitfalls of my solution. Any articles and examples will also be very helpfull.
Thanks in advance.
These sound like standard problems associated with distributed, indpependent, databases. You can no longer delegate all relationships to the database and get a result aggregating them in some way. You have to do the work yourself by calling one database, then the other.
For a case like this:
Fetching users that liked particular article
You would look up the "likes" database to determine user IDs of those who liked it, then look up the "users" database to determine user details such as name and avatar.
Most patterns follow standard database advice, e.g. in the above example, you could follow the performance-oriented pattern of de-normalising - store user data such as name and avatar against each "like", as long as you feel the extra storage and burden of keeping it consistent is justified by the reduction in queries (probably too many Likes to justify this).
Another important practice is using bulk queries to avoid N+1 queries. This is what Rails does with the includes syntax, but you may have to do it yourself here. In my example, it should only take two queries because the second query should get all required user data in one go, by querying for users matching the list of user IDs.
Finally, I'd suggest you try to abstract things. This kind of code gets messy fast, so be sure to build a well-encapsulated data layer that isolates application code from dealing with the mess of multiple databases.

Web app roll out

I've been developing web apps some years now, actually as a hobby. When I write something, unsing Laravel, Sails.js, or Meteor and I add a feature, I upload it and it's there, for everyone.
However, I've always been wondering how bigger sites like facebook manage to roll out features to just some users. Do they push their changes to just some servers? But in that case - how do they manage the make the selected users access just these servers?
Or some db entry to see if the user has access to the feature/ version?
So how does it work?
Really interested in this :)
Large sites like Facebook use a technique called Feature toggles to control the functionality that is active at run-time. The following blog article describes Facebook's approach:
https://abhishek-tiwari.com/post/decoupling-deployment-and-release-feature-toggles