A standalone service for managing blog application users. This include administrators, authors, readers and moderators.
This is a web application that manages the users of a blogging application(A Medium clone). The application enables the various users to register as well as manage their accounts (view, update, delete.) Other functionality includes:
- Authors can report offensive authors
- Authors can subscribe to other authors and the subscribers can be sent notification emails.
- Moderators can flag offensive authors and admins can suspend offensive author accounts.
It's pretty easy to use the application. On the home page (http://localhost:5000/apidocs):
- Create an account (post details through register route)
- Send a confirmation email (post email address and user id theough the send_confirm_email route)
- Confirm email address (submit the user id and token from step 2)
- Log in using the login route (submit your email and password)
- Use the access token from step 4 to authorize yourself.
- Access other functionalities such as user update, viewing, deletion.
Here is how to set up the application locally:
-
Clone the application repo:
git clone https://github.com/twyle/Medium-Clone-User-Management-Service.git
-
Navigate into the cloned repo:
cd Medium-Clone-User-Management-Service
-
Create a Virtual environment:
python3 -m venv venv
-
Activate the virtual environmnet:
source venv/bin/activate
-
Install the project dependancies:
pip install --upgrade pip # update the package manager pip install -r requirements.txt
-
Create the environment variables for the service:
touch .env
Then paste the following into the file:
FLASK_DEBUG=True FLASK_ENV=development FLASK_APP=manage.py SECRET_KEY=secret-key POSTGRES_HOST=localhost POSTGRES_USER=lyle POSTGRES_PASSWORD=lyle POSTGRES_DB=lyle POSTGRES_PORT=5432 MAIL_USERNAME=<mail-user-name> MAIL_PASSWORD=<mail-password> MAIL_SERVER=<mail-server> MAIL_PORT=465 MAIL_USE_SSL=True MAIL_DEFAULT_SENDER=<default-email> S3_BUCKET=<s3-bucket-name> AWS_ACCESS_KEY=<aws-access-key> AWS_ACCESS_SECRET=<aws-secret-key>
Then create the database secrets:
cd services/database touch .env
Then paste the following into the file:
POSTGRES_DB=lyle POSTGRES_PORT=5432 POSTGRES_USER=postgres POSTGRES_PASSWORD=lyle
-
Start the database containers:
docker-compose -f database/docker-compose.yml up --build -d
-
Create the database migrations:
flask db migrate -m "Initial migration." flask db upgrade
-
Start the services:
python manage.py run
-
View the running application
Head over to http://0.0.0.0:5000/apidocs
-
Services
The application consists of a single service.
- User Management Service
This service is resposible for the registration of new users, as well as the authentication and authorization of registered users. The routes include:
Route Method Description 'api/v1/auth/register/admin' POST Register a new admin. 'api/v1/auth/register/author' POST Register a new author. 'api/v1/auth/register/moderator' POST Register a new moderator. 'api/v1/auth/login' POST Login as a registered user. 'api/v1/auth/logout' POST Logout as a logged in user. 'api/v1/auth/confirm_email' GET Confirm email address. 'api/v1/auth/reset_password' POST Reset password . 'api/v1/author' DELETE Delete a author. 'api/v1/author' PUT Update author info. 'api/v1/author' GET Get a author's info. 'api/v1/authors' GET List all authors. 'api/v1/author/follow' GET Follow an author. 'api/v1/author/followers' GET Get an authors followers. 'api/v1/author/follows' GET A list of author this author follows. 'api/v1/author/subscribe' GET Subscribe to an author. 'api/v1/author/subscribed_to' GET Find an authors subscribes. 'api/v1/author/subscribers' GET Get anauthors subscribers. 'api/v1/author/unfollow' GET Unfollow an author. 'api/v1/author/unsubscribe' GET Unsubscribe to an author. 'api/v1/admin' DELETE Delete a admin. 'api/v1/admin' PUT Update admin info. 'api/v1/admin' GET Get a admins info. 'api/v1/admins' GET List all admins. 'api/v1/moderator' DELETE Delete a moderator. 'api/v1/moderator' PUT Update moderator info. 'api/v1/moderator' GET Get a moderators info. 'api/v1/moderators' GET List all moderators. 'api/v1/report/author' POST Report an offensive author. 'api/v1/report/authors' GET List reported authors. 'api/v1/flag/author' POST Flag an offensive author. 'api/v1/flag/authors' GET List flagged authors. 'api/v1/suspend/author' POST Suspend an offensive author. 'api/v1/suspend/authors' GET List suspended authors. This service uses Postgres to store the user info, AWS S3 to store the images, AWS SES to send the emails and celery for the email sending and photo upload.
-
Database
The application uses Postgres and AWS S3. The postgres database is used to store user details. The AWS S3 bucket is used to store the profile pictures.
-
Security
The application uses JSON Web Tokens to authorize access to protected routes. The passwords are also encrypted.
- Fork it https://github.com/twyle/repo-template/fork
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
Lyle Okoth – @lylethedesigner on twitter
lyle okoth on medium
My email is [email protected]
Here is my GitHub Profile
You can also find me on LinkedIN
Distributed under the MIT license. See LICENSE
for more information.