Mattermost is an open source Slack alternative. It's written in Golang and React and runs as a single Linux binary with MySQL or PostgreSQL. Use the features you like (file sharing, real-time group chat and webhooks—to name a few) and access the source code.