/ ENGINEERING, SOFTWARE DEVELOPMENT, WEB SERVICES

Writing (Another) Avatar Service

This story probably sounds familiar: you are in the middle of implementing a new webapp, writing th code necessary to support user profiles. You realize that you want to support user avatars (because users absolutely want to be able to choose their avatar), but you don’t want to create and maintain a service just to host images of users.

You could use Gravatar, but the problem with this is that Gravatar requires that users upload their avatars using the Gravatar website and doesn’t allow you to provide your users a convenient upload mechanism directly from within their profile on your app.

After having written 3 or 4 of these myself, I realized they basically take the same form. So, when I was faced with this problem again with my current project, I decided I wanted to write a single, self-contained microservice that could be reusable whenever I (or someone else) needed it. This also gave me a chance to write a web service in Rust and to renew some of my skills with Docker.

Enter Archetype. This is a small service designed to provide avatars that you can use for your web app. It has a very simple API that can be used with both image/jpeg and image/png files. To set it up, perform the following on your server that has the docker daemon running:

git clone git@github.com:FoamFactory/archetype
cd archetype

# Edit docker-compose.yml to assign the ALLOWED_HOSTS variable properly.
# Since this is the only security level available right now, you must
# specify at least one IP address for machines you want to be able to
# access the avatar service.

docker-compose up -d

Yup, that’s it! If you want, I’ll even set it up for you and maintain it, for $36/year (slightly more if you want me to setup a Linode instance that you can own and maintain yourself). Just sent me a quick email at scott{at}jwir3.com and I’ll take care of it for you. And, of course, patches are accepted for things that need changing.

Hopefully, this saves you time in the future from having to re-write avatar services from scratch every time you create a new app that requires them.

jwir3

Scott Johnson

I'm a highly skilled software engineer with 15+ years of experience in computer graphics and computational geometry across a variety of technical stacks. Passionate about open-source software, high-performance rendering, clean code design, and learning while mentoring other developers through code review, individual pairing sessions, and leadership principles.

Read More